I'm working on a script to add the printed date to drawings. I have most of it worked out except for the part that adds a new textbox for the timestamp if one doesn't exist already. Old drawings before the templates are updated will need to have the text added.
Public Sub SheetTextAdd() ' Set a reference to the GeneralNotes object Dim oGeneralNotes As GeneralNotes Set oGeneralNotes = ThisApplication.ActiveDocument.ActiveSheet.DrawingNotes.GeneralNotes Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry Dim sText As String sText = "PRINTED: date goes here with other code" Dim oGeneralNote As GeneralNote Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(0.5, 2), sText) oGeneralNotes.Item(oGeneralNotes.Count()).TextStyle.FontSize = 0.6 * 0.254 oGeneralNotes.Item(oGeneralNotes.Count()).TextStyle.Rotation = pi / 2 End Sub
I found this code in the help and I've edited it some. It's inserting the text fine and resizing it but the rotation is not working. Any value other than 0 for the rotation does nothing and the help says it must be 0, pi/2, pi, or 1.5pi. I also know the command to add the text can have a third parameter for textstyle but I'm unsure of how that is supposed to be formatted. Any help would be appreciated.
Try adding the below code before using pi
Dim pi As Double
pi = Atn(1) * 4
GeneralNote.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter
HorizontalTextAlignmentEnum Enumerator
kAlignTextCenter | 19969 | Text centered about the supplied point. |
kAlignTextLeft | 19970 | Text left-justified about the supplied point. |
kAlignTextRight | 19971 | Text right-justified about the supplied point. |
IN case you werent aware, you can find all of the syntax through the Question mark in top right of inventor > Community Resources > Programming Help
and also the API object model found here:
http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112