Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic dated sketch symbol

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Formsprag
525 Views, 4 Replies

iLogic dated sketch symbol

I have a "Temporary Drawing Stamp" sketch symbol that I am inserting through iLogic. It is a prompted entry symbol that requires a date. Is there a way to make the code default to the current date?

 

Here's the code:

'Sub Main() 
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisDoc.Document 
 
' Obtain a reference to the desired sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition _
       = oDrawDoc.SketchedSymbolDefinitions.Item("Temporary Dwg Stamp")
Dim oPromptStrings As String() = {"Enter Date"}

 
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
 
'create insertion point, coordinates - in cm !
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(10, 10)

    Dim sPromptStrings(0) As String       
    sPromptStrings(0) = "Date"

 
' Add an instance of the sketched symbol definition to the sheet.
' Rotate angle = 0 radians,
' scale = 1 when adding
' no prompt text
Dim oSketchedSymbol As SketchedSymbol _
       = oSheet.SketchedSymbols.Add( _
             oSketchedSymbolDef, _
             oInsertionPoint, _
             0, 1, sPromptStrings)
'End Sub
4 REPLIES 4
Message 2 of 5

Hi @Formsprag 

 

in iLogic you can use DateString for this

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

aaa.png

 

Message 3 of 5

Hi

 

Great iLogic rule, almost exactly what I needed. 

But I also need the current time. How would you add the current time to a second prompted entry in a sketch symbol? I can't work it out my self.

Message 4 of 5

Here's what I came up with: (Remember your Sketch Symbol has to have two prompt entry fields)

'Sub Main() 
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisDoc.Document 
 
' Obtain a reference to the desired sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition _
       = oDrawDoc.SketchedSymbolDefinitions.Item("Temporary Dwg Stamp")
Dim oPromptStrings As String() = {"Enter Date"} 

 
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
 
'create insertion point, coordinates - in cm !
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(10, 10)

    Dim sPromptStrings(1) As String       
    sPromptStrings(0) = DateString
	sPromptStrings(1) = TimeString

 
' Add an instance of the sketched symbol definition to the sheet.
' Rotate angle = 0 radians,
' scale = 1 when adding
' prompt text
Dim oSketchedSymbol As SketchedSymbol _
       = oSheet.SketchedSymbols.Add( _
             oSketchedSymbolDef, _
             oInsertionPoint, _
             0, 1, sPromptStrings)

 

Message 5 of 5

Thank you! Worked like a charm. 

 

The only thing I need to fix now is the date format. The DateString format is not the same as iProperties date format, which is th one I'd like to use. Is there a simple solution to fix this?

 

Inventor.iLogic.DateFormat.jpg

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report