using ilogic to place content centre parts into active doc (NOT ThisAssembly)

using ilogic to place content centre parts into active doc (NOT ThisAssembly)

mark.almack
Enthusiast Enthusiast
608 Views
1 Reply
Message 1 of 2

using ilogic to place content centre parts into active doc (NOT ThisAssembly)

mark.almack
Enthusiast
Enthusiast

I'm trying to place some content centre components into an assembly that the rule is NOT in. So instead of "This Assembly.Geometry.Point" I need something like "ActiveAssembly.Geometry.Point." Is there such a thing?

 

pos = ThisAssembly.Geometry.Point(x, y, z)

Dim componentA = Components.AddContentCenterPart("Shoulder Screw:" & i, "Fasteners", 
												"Automotion Components Shoulder Screw", 
                                            	 ShoulderScrewName, pos, grounded := True, 
                                           		 visible := True, appearance := Nothing)

 Thanks in Advance!

0 Likes
609 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor

You can use the following code to place a occurence (or cc part) in a sub assembly.

Dim doc As AssemblyDocument = ThisApplication.ActiveDocument
Dim subAssemblyOccurence As ComponentOccurrence = doc.ComponentDefinition.Occurrences.ItemByName("Assembly1:1")
Dim subAssembly As AssemblyDocument = subAssemblyOccurence.ReferencedDocumentDescriptor.ReferencedDocument
Dim matrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()

' TODO:
' - create Content center part if it does Not exist localy
' - get full file name 
' - see: https://adndevblog.typepad.com/manufacturing/2013/06/insert-content-center-part.html

Dim occ As ComponentOccurrence = subAssembly.ComponentDefinition.Occurrences.Add(contentCenterFullFileName, matrix)

or if you want to add it to a random assembly then you can use:

Dim assemblyDoc As AssemblyDocument = ThisApplication.Documents.Open("C:\temp\assembly1.iam")
Dim matrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()

' TODO:
' - create Content center part if it does Not exist localy
' - get full file name
' - see: https://adndevblog.typepad.com/manufacturing/2013/06/insert-content-center-part.html
assemblyDoc.ComponentDefinition.Occurrences.Add(contentCenterFullFileName, matrix)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes