Hello,
There are two cases, that should behave the same, but they don't.
First program works normally. Inventor generates a circular Pattern with the given Part.
' Part referenced in Obejct-Collection-Object
o_ObjectCollection (is defined)
' reference an Axis of the Assembly
Dim o_AssyDef As AssemblyComponentDefinition
o_AssyDef = o_AssyDoc.ComponentDefinition
Dim o_WorkAxis As WorkAxis
o_WorkAxis = o_AssyDef.WorkAxes(3)
' Add Circular Pattern with Axis from Assembly
Dim o_CircOccPatt As CircularOccurrencePattern
o_CircOccPatt = o_AssyDef.OccurrencePatterns.AddCircularPattern _
(o_ObjectCollection, o_WorkAxis, True, "90 deg", 3)
Now, the second case, I try to take the Work Axis from a Part, that is placed in the Assembly,
but Inventor does not generate the Pattern. If I set the Axis visible, or even rename it, it works. But the AddCircularPattern does not work.
' Part referenced in Obejct-Collection-Object
o_ObjectCollection (is defined)
' reference an Axis from Part, placed in Assembly
Dim o_CompOcc As ComponentOccurrence
o_CompOcc = o_AssyDoc.ComponentDefinition.Occurrences.Item(4)
Dim o_PartDoc As PartDocument = o_CompOcc.Definition.Document
Dim o_PartDef As PartComponentDefinition = o_PartDoc.ComponentDefinition
Dim o_WorkAxis As WorkAxis
o_WorkAxis = o_PartDef.WorkAxes.Item(3)
o_WorkAxis.Visible = True
' Add Circular Pattern with Axis from Part in the Assembly
Dim o_CircOccPatt As CircularOccurrencePattern
o_CircOccPatt = o_AssyDef.OccurrencePatterns.AddCircularPattern _
(o_ObjectCollection, o_WorkAxis, True, "90 deg", 3)
I hope somebody can help me, because I really need this functionality.
Thank you very much,
abrink
Solved! Go to Solution.
I'd be happy to take a look if you upload a dataset (part+assembly) and code (simple complete subs) that show the behavior. Posting incomplete code snippets without models is stretching the limits of free advice.
For future API related questions, you'll probably have better luck with the customization forum: http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
Abrink100,
Could you also attach the dataset? (part and assembly files)
Thanks,
Jan
I looked into this one closer and what you need to do is create a proxy object for the workaxis. The proxy object then can be passed as in input argument to AddCircularPattern(). What your code does is that it directly retrieves the axis from the part document, but we need to know which occurrence has been used...
Try to change your script to something like this:
Public Sub AddCircularPattern_Part_Axis()
Dim o_AssyDoc As Inventor.AssemblyDocument
Set o_AssyDoc = ThisApplication.ActiveDocument
Dim o_AssyDef As AssemblyComponentDefinition
Set o_AssyDef = o_AssyDoc.ComponentDefinition
Dim o_CompOccs As ComponentOccurrences
Set o_CompOccs = o_AssyDef.Occurrences
Dim o_ObjectCollection As Inventor.ObjectCollection
Set o_ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
o_ObjectCollection.Clear
o_ObjectCollection.Add o_CompOccs.Item(1)
Dim o_CompOcc As ComponentOccurrence
Set o_CompOcc = o_AssyDef.Occurrences.Item(1)
Dim o_PartDef As PartComponentDefinition
Set o_PartDef = o_CompOcc.Definition
Dim o_WorkAxis As WorkAxis
Set o_WorkAxis = o_PartDef.WorkAxes.Item(3)
Dim o_PWorkAxis As WorkAxisProxy
Call o_CompOcc.CreateGeometryProxy(o_WorkAxis, o_PWorkAxis)
Dim o_CircOccPatt As CircularOccurrencePattern
Set o_CircOccPatt = o_AssyDef.OccurrencePatterns.AddCircularPattern(o_ObjectCollection, o_PWorkAxis, True, "90 deg", 3)
End Sub
Hello Mr. Varholik,
thank you very much, it works now the first time i tried it.
abrink100