Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IV2012 API - AddCircularPattern doen't work with Axis from Part in Assembly

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
abrink100
543 Views, 5 Replies

IV2012 API - AddCircularPattern doen't work with Axis from Part in Assembly

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

5 REPLIES 5
Message 2 of 6
alewer
in reply to: abrink100

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

Message 3 of 6
abrink100
in reply to: alewer

Hello alewer, thanks for your help. I tried to put it correctly into two separate subs. The second Sub is the funcionality i need, but it doesn't work. The first one works. Atteched you will find the files. Thank you very much for help. Mr. Brinkmann Public Sub AddCircularPattern_Assembly_Axis(ByVal o_AssyDoc As Inventor.AssemblyDocument) ' reference Sheet-Part in Obejct-Collection-Object Dim o_CompOccs As ComponentOccurrences o_CompOccs = o_AssyDoc.ComponentDefinition.Occurrences ' ObjectCollection erstellen und das Element festlegen Dim o_ObjectCollection As Inventor.ObjectCollection o_ObjectCollection = o_Application.TransientObjects.CreateObjectCollection o_ObjectCollection.Clear() o_ObjectCollection.Add(o_CompOccs.ItemByName("Sheet")) ' 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(1) ' X-Axis in Origin-Dir in Assembly ' 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) End Sub Public Sub AddCircularPattern_Part_Axis(ByVal o_AssyDoc As Inventor.AssemblyDocument) ' reference Sheet-Part in Obejct-Collection-Object Dim o_CompOccs As ComponentOccurrences o_CompOccs = o_AssyDoc.ComponentDefinition.Occurrences ' ObjectCollection erstellen und das Element festlegen Dim o_ObjectCollection As Inventor.ObjectCollection o_ObjectCollection = o_Application.TransientObjects.CreateObjectCollection o_ObjectCollection.Clear() o_ObjectCollection.Add(o_CompOccs.ItemByName("Sheet")) ' reference an Axis from Pipe-Part, placed in Assembly Dim o_CompOcc As ComponentOccurrence o_CompOcc = o_AssyDoc.ComponentDefinition.Occurrences.ItemByName("Pipe") 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) ' Z-Axis of Pipe-Part o_WorkAxis.Visible = True ' Add Circular Pattern with Axis from Assembly Dim o_AssyDef As AssemblyComponentDefinition o_AssyDef = o_AssyDoc.ComponentDefinition Dim o_CircOccPatt As CircularOccurrencePattern o_CircOccPatt = o_AssyDef.OccurrencePatterns.AddCircularPattern _ (o_ObjectCollection, o_WorkAxis, True, "90 deg", 3) End Sub
Message 4 of 6
JanVarholik
in reply to: abrink100

Abrink100,

 

Could you also attach the dataset? (part and assembly files)

 

Thanks,

Jan

Message 5 of 6
JanVarholik
in reply to: abrink100

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

Message 6 of 6
abrink100
in reply to: JanVarholik

Hello Mr. Varholik,

 

thank you very much, it works now the first time i tried it.

 

abrink100

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report