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
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.
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
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
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
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.
I want the highlight effect of the interference volumn as in the command. The API does not provide that
Get the InterferenceResult.InterferenceBody (which is a SurfaceBody) and display it using ClientGraphics?
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
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
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.
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
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
I wouldn't post code on here if I hadn't tested it myself.... 🙂
1. Two interfering parts.
2. Select them both
3. Run macro, interference is left behind
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
I add a definition line in your code: Dim oClientGraphics As ClientGraphics.
And create two parts as yours and make an assembly, want to repeat your success, still not working.
Stop at (see attached error massage): XXXXXX.....InterferenceBody
I am running on Inventor 2011. But I don't think this is a new feature if there is any.
Thanks
Very strange. I should have mentioned that I am using Inventor 2013 but I don't know if the InterferenceBody is new since 2011. I can't imagine it would be.
Maybe post your dataset and I'll try it in 2013.
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
I spoke to soon..... The InterferenceBody was new in Inventor 2012 sorry.
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
Yes. The code works for Inventor 2013, but not 2011.
So I still have the question: is it possible to provide 2 inputs to run Inventor commands using API? ^_^
Thanks
Can't find what you're looking for? Ask the community or share your knowledge.