Inventor macro to create another macro

Inventor macro to create another macro

Anonymous
Not applicable
444 Views
3 Replies
Message 1 of 4

Inventor macro to create another macro

Anonymous
Not applicable

Hello fellows,

I am trying to create an Inventor macro to create another "hello" macro.
That means, first check if the "hello" macro exists and if not, create it with a MsgBox("hello world")


Does anyone know how to do this?

 

Thanks, Robert

0 Likes
445 Views
3 Replies
Replies (3)
Message 2 of 4

AlexFielder
Advisor
Advisor

I would recommend you search these forums for the following:

 

ilogicvb.automation

 

This is how you gain access to the iLogic Automation Object which will allow you to add an iLogic rule from a separate iLogic rule.

0 Likes
Message 3 of 4

bradeneuropeArthur
Mentor
Mentor
I have this example.
I could send you this earliest on Monday...

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 4

bradeneuropeArthur
Mentor
Mentor

Hi,

Earlier then expected:

 

Public Sub SheetMetalAutoMacroAdd()

    Dim VBProj As VBIDE.VBProject
    Dim VBComp As VBIDE.VBComponent
            
    Set VBProj = ThisApplication.ActiveDocument.VBAProject.VBProject '.VBE.VBProjects
    On Error Resume Next
    If Not VBProj.VBComponents.Item(3).Name = "X" Then
        Set VBComp = VBProj.VBComponents.Add(vbext_ct_StdModule)
        VBComp.Name = "X"
    End If
    
    On Error Resume Next
    If Not VBProj.VBComponents.Item(4).Name = "Y" Then
        Set VBComp = VBProj.VBComponents.Add(vbext_ct_StdModule)
        VBComp.Name = "Y"
    End If
    
        For Each oVBProject In ThisApplication.VBE.VBProjects
        Debug.Print oVBProject.Name
        If oVBProject.Name = "DocumentProject" Then
    
           For Each oVBComponent In oVBProject.VBComponents
    
                If oVBComponent.Name = "X" Then
                    MsgBox oVBComponent.Name
    
                    oVBComponent.CodeModule.DeleteLines 1, oVBComponent.CodeModule.CountOfLines
                    oVBComponent.CodeModule.AddFromFile ("C:\_ExportedModules\X.txt")
                End If
    
                If oVBComponent.Name = "Y" Then
                    MsgBox oVBComponent.Name
    
                    oVBComponent.CodeModule.DeleteLines 1, oVBComponent.CodeModule.CountOfLines
                    oVBComponent.CodeModule.AddFromFile ("C:\_ExportedModules\Y.txt")
                End If
            Next
    End If
           Next

End Sub  

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes