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: 

VBA - Add and edit a General Note

6 REPLIES 6
Reply
Message 1 of 7
pball
1862 Views, 6 Replies

VBA - Add and edit a General Note

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.

6 REPLIES 6
Message 2 of 7
pball
in reply to: pball

bump for help
Message 3 of 7
saseendrankombath
in reply to: pball

Try adding the below code before using pi

 

Dim pi As Double
pi = Atn(1) * 4

Message 4 of 7

hi!

 

and for oGeneralNotes HorizontalJustification?

anybody know?

Message 5 of 7

GeneralNote.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter

 

HorizontalTextAlignmentEnum Enumerator

kAlignTextCenter19969Text centered about the supplied point.
kAlignTextLeft19970Text left-justified about the supplied point.
kAlignTextRight19971Text right-justified about the supplied point.

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 7

Thanks alot Mechmachineman 🙂

Message 7 of 7

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


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type

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

Post to forums  

Autodesk Design & Make Report