running ilogic form forms (exe)

running ilogic form forms (exe)

Darkforce_the_ilogic_guy
Advisor Advisor
871 Views
7 Replies
Message 1 of 8

running ilogic form forms (exe)

Darkforce_the_ilogic_guy
Advisor
Advisor

I have this problem .. I have a lot of ilogic files i want to run form a forms (Exe).  but the problem is that all the ilogic files work .. if you run them ,,, or by aktivet form VBA Form... and run by marco .. but for some reason they do not work if I run them form  a form in exe program.  well some do ... but not all ...and it even not the same error that pops op

 

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim invApp As Inventor.Application
        invApp = GetObject(, "Inventor.Application")

        Dim addIn As ApplicationAddIn
        Dim addIns As ApplicationAddIns
        addIns = invApp.ApplicationAddIns
        For Each addIn In addIns
            If InStr(addIn.DisplayName, "iLogic") > 0 Then
                addIn.Activate()
                Dim iLogicAuto As Object
                iLogicAuto = addIn.Automation
                Exit For
            End If
        Next
        'Debug.Print(addIn.DisplayName)


        'Dim RuleName1 As String
        Dim EXTERNALrule
        EXTERNALrule = "Exportdatatocalworksheet"

        'Dim RuleName2 As String
        'INTERNALrule = "Rule2"

        Dim oDoc As Document

        oDoc = invApp.ActiveDocument
        If oDoc Is Nothing Then
            MsgBox("Missing Inventor Document")
            Exit Sub
        End If
        Dim iLogicAuto2 = addIn.Automation

        iLogicAuto2.RunExternalRule(oDoc, EXTERNALrule) 'for external rule



    End Sub

 

this code give me error 

Current thread must be set to single thread apartment (STA)

 

I do not get it ... the Ilogic codes should be ok ... we have use them for a long time ... what i just need to do is hit a buttom and run a ilogic code in inventor .... can anyone tell me why that is soo hard?...and and  why some code run fine as normal ... som does not work 

 

0 Likes
872 Views
7 Replies
Replies (7)
Message 2 of 8

bradeneuropeArthur
Mentor
Mentor
is this Exe done with vb.net?

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 3 of 8

bradeneuropeArthur
Mentor
Mentor

Try this piece of code:

Dim invApp As Inventor.Application
        invApp = GetObject(, "Inventor.Application")

        Dim addIn As ApplicationAddIn = Nothing
        Dim addIns As ApplicationAddIns
        Dim iLogicAuto As Object = Nothing
        addIns = invApp.ApplicationAddIns
        For Each addIn In addIns
            If InStr(addIn.DisplayName, "iLogic") > 0 Then
                addIn.Activate()
                ' Object
                iLogicAuto = addIn.Automation

                Exit For
            End If
        Next
        'Debug.Print(addIn.DisplayName)



        'Dim RuleName1 As String
        Dim EXTERNALrule As String
        EXTERNALrule = "Exportdatatocalworksheet"

        iLogicAuto.RunexternalRule(invApp.ActiveDocument, EXTERNALrule)
        'Dim RuleName2 As String
        'INTERNALrule = "Rule2"

        Dim oDoc As Inventor.Document

        oDoc = invApp.ActiveDocument
        If oDoc Is Nothing Then
            MsgBox("Missing Inventor Document")
            Exit Sub
        End If

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 8

I am not 100% sure... i have select visual basic and add ref. Inventor.. and importe inventor at the top...

The funny thing is that some ilogic code.. runs and other does not..i am not sure why.. because all of the ilogic code works if they are run form inventor or using vba form form inventor vba editor



0 Likes
Message 5 of 8

please share the complete project

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 6 of 8

are you taking about the project in Microsoft Visual studio.. or also all the ilogic files as well ?

 

as far as i can see ... at lest 2 types of error ... one what is case then I type to change color of part/assembly .. and a other when I use excel(I also use copy Paste)

 

but the ilogic that change Enable prehighlight and the 2 code that Save JPG or Step file and one that try to reset browsernotes work ... might be more error or more that work ... but have not have time to test them all jet

0 Likes
Message 7 of 8

The Visual studio project folder.

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 8 of 8

I just found out the the error is  cause be this line of code

 

Clipboard.SetText(oPreprice)

 

 

I use this code to copy an string to Clipboard (For Copy & paste). 

0 Likes