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
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
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
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.
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)
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?
Can't find what you're looking for? Ask the community or share your knowledge.