Inventor Customization

Reply
Active Contributor
liminma8458
Posts: 33
Registered: ‎07-28-2009
Message 1 of 14 (216 Views)

Question on Running commands using API: how to provide 2 inputs through API?

216 Views, 13 Replies
02-06-2013 10:52 AM

Hi

 

Brian Ekins gave a good information on how to Run Commands Using the API. And he also shows API can provide one sets of input to the command.

 

In my case, the Inventor command "analyze interference" need two sets of inputs. I tried to feed the commands with two selectset input throght API (see attached code). But the command looks like only take one set of them.So the behavior is not what I want.

 

So if it is possible,  how to provide 2 set of pre-defined input to inventor commands throught API?

 

Thank you very much for the help.

 

Limin

 

 

 

Active Contributor
gavin.b
Posts: 53
Registered: ‎12-07-2011
Message 2 of 14 (210 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 12:46 PM in reply to: liminma8458

I believe the problem you are having here is because the dialog box still shows and wants you to select "OK."

As you can't provide the "OK" via the API, you can't complete the command.

 

In Brian Ekins' blog post he said this:

 

" Most commands, even if they support pre-selection of entities, will still allow additional selection so they will still require user input.  For example the Fillet command will take any pre-selected edges as input but still displays the dialog to allow the user to select more edges and specify any other options."

 

I don't think you can finish the analyze interference command through the API call.

Active Contributor
gavin.b
Posts: 53
Registered: ‎12-07-2011
Message 3 of 14 (205 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 12:51 PM in reply to: liminma8458

Why not use the method that is already provided in the API rather than running the command using CommandManager?

 

AssemblyComponentDefinition.AnalyzeInterference( Set1 As ObjectCollection, [Set2] As Variant ) As InterferenceResults

Active Contributor
liminma8458
Posts: 33
Registered: ‎07-28-2009
Message 4 of 14 (204 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 12:52 PM in reply to: gavin.b

The program runs well, but only take the first set to do the analysis. What I want is to analyse the first set against the second set.

Active Contributor
liminma8458
Posts: 33
Registered: ‎07-28-2009
Message 5 of 14 (203 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 12:54 PM in reply to: liminma8458

I want the highlight effect of the interference volumn as in the command. The API does not provide that

Active Contributor
gavin.b
Posts: 53
Registered: ‎12-07-2011
Message 6 of 14 (201 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 12:56 PM in reply to: liminma8458

Get the InterferenceResult.InterferenceBody (which is a SurfaceBody) and display it using ClientGraphics?

Active Contributor
liminma8458
Posts: 33
Registered: ‎07-28-2009
Message 7 of 14 (189 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 01:02 PM in reply to: gavin.b

Just wonder how to reach the object of "InterferenceResult.InterferenceBody", the Interferenceresult only shows centroid, occurrenceone,occurrencetwo, type and volume (double type). oResults.InterferenceBody returns error. as attached

 

How to do that? thanks

Active Contributor
gavin.b
Posts: 53
Registered: ‎12-07-2011
Message 8 of 14 (183 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 01:22 PM in reply to: liminma8458

Try this:

 

Public Sub ShowInterference()

    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oCompDef As ComponentDefinition
    Set oCompDef = oDoc.ComponentDefinition
    
    Dim oSelect1 As ComponentOccurrence
    Set oSelect1 = oDoc.SelectSet.Item(1)
    Dim oSelect2 As ComponentOccurrence
    Set oSelect2 = oDoc.SelectSet.Item(2)
    
    Dim oCheckSet As ObjectCollection
    Set oCheckSet = ThisApplication.TransientObjects.CreateObjectCollection
    
    Call oCheckSet.Add(oSelect1)
    Call oCheckSet.Add(oSelect2)
    
    Dim oIntBody As SurfaceBody
    Set oIntBody = oDoc.ComponentDefinition.AnalyzeInterference(oCheckSet).Item(1).InterferenceBody
        
    ' Create the ClientGraphics object.
    Set oClientGraphics = oCompDef.ClientGraphicsCollection.Add("Sample3DGraphicsID")

        ' Create a new graphics node within the client graphics objects.
        Dim oSurfacesNode As GraphicsNode
        Set oSurfacesNode = oClientGraphics.AddNode(1)

        Dim oBody As SurfaceBody
        Set oBody = oIntBody

        ' Create client graphics based on the transient body
        Dim oSurfaceGraphics As SurfaceGraphics
        Set oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody)

        ' Update the view to see the resulting curves.
        ThisApplication.ActiveView.Update


End Sub

 

Select two components that interfere and then runthe routine. After you have run it, hide the 2 components and you'll see the interference body left over.

Active Contributor
liminma8458
Posts: 33
Registered: ‎07-28-2009
Message 9 of 14 (176 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 02:07 PM in reply to: gavin.b

Set oIntBody = oDoc.ComponentDefinition.AnalyzeInterference(oCheckSet).Item(1).InterferenceBody

 

The above line does NOTwork. InterferenceBody is not recognized.  "oDoc.ComponentDefinition.AnalyzeInterference(oCheckSet).Item(1) " only has centroid, occurrenceone,occurrencetwo, type and volume (double).

 

More advise?

 

Thanks

Active Contributor
gavin.b
Posts: 53
Registered: ‎12-07-2011
Message 10 of 14 (173 Views)

Re: Question on Running commands using API: how to provide 2 inputs through API?

02-06-2013 02:14 PM in reply to: liminma8458

I wouldn't post code on here if I hadn't tested it myself.... :smileyhappy:

 

1. Two interfering parts.1.JPG

 

2. Select them both

2.JPG

 

3. Run macro, interference is left behind

3.JPG

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube