Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sub-subassembly contraints

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
m_baczewski
177 Views, 2 Replies

Sub-subassembly contraints

Hi,


I would like to insert a subassembly from the main assembly into a sub-subassembly and insert contraints. I know how to insert the part, but unfortunately, I can't figure out how to link these two elements in the sub-subassembly. I keep getting an error.

I've tried something like this, but it gives me an 'Invalid Parameter' error.

Constraints.AddFlush("W1", {"RDZEN", "Platforma uchylna", "Wyciągarka:1"}, "P1",{"RDZEN", "Platforma uchylna" , "Spawany"}, "P1")

 

The planes with that name exist because if I change it, I get an error saying that such an element was not found in that part/model.

Is it possible to add constraints to two parts/assemblies from the main assembly

2 REPLIES 2
Message 2 of 3
WCrihfield
in reply to: m_baczewski

Hi @m_baczewski.  I see that you are using the iLogic snippet for adding a flush constraint.  The online help page for that method is below:

IManagedConstraints.AddFlush Method 

Is it possible that constraint name "W1" is already being used?  If so, that might cause a problem like that.  I honestly do not use that Constraints.AddFlush method for situations that complex, and I am not familiar enough with your models, so it is difficult to determine what could be causing the error remotely.  My guess is that you simply can not create a flush constraint between those two sub-sub components from the top assembly using that snippet.  Since both components are down 2 levels within the same sub assembly, the constraint would need to be created at that parent sub assembly level, not at the top assembly level.  That leaves 2 options.  Open or Edit that parent sub assembly, then create the constraint between the two child components ; or use Inventor API code to do that task, and dig down through the assembly structure to that parent sub assembly component's 'Definition' (an AssemblyComponentDefinition), then use its AssemblyComponentDefinition.Constraints.AddFlushConstraint method.  But in that API route, you would need to get the 'proxy' objects in the context of that sub assembly that represent the work features within those two components, not just their names.  And as you might have guessed, that will require quite a bit more code (and more complication) to accomplish.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3
m_baczewski
in reply to: WCrihfield

Hi  @WCrihfield thank you for your response. I don't want to open a sub-subassembly to perform a constraint operation; I would like to do it from the top-level assembly.

Could you explain this to me with a simple example? I can find surfaces through the API, but unfortunately, I don't know how to perform a constraint operation on a sub-subassembly. How can I work on a sub-subassembly from the top-level assembly?

 

Edit:

When I re-read your message and sat down to a simple assembly, I managed to add a constraint in a subassembly. You've been very helpful; I'm attaching the code that inserts constraints in any subassembly from the top-level assembly using the API>iLogic.

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument ' top assembly

Dim oAsm As AssemblyDocument 
oAsm = oDoc.AllReferencedDocuments.Item(2) ' sub sub assembly

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsm.ComponentDefinition

Dim compOcc1 As ComponentOccurrence = oAsm.ComponentDefinition.Occurrences.Item(1) ' part in sub sub assembly
Dim compOcc2 As ComponentOccurrence = oAsm.ComponentDefinition.Occurrences.Item(2) ' part in sub sub assembly

Dim oPlane1 As WorkPlane
oPlane1 = compOcc1.Definition.Workplanes("P3") 'plane in part
Dim oPlane2 As WorkPlane
oPlane2 = compOcc2.Definition.Workplanes("P4") 'plane in part

Logger.Info(oPlane1.Name)
Logger.Info(oPlane2.Name)


Dim oproxyPlane1 As WorkPlaneProxy
compOcc1.CreateGeometryProxy(oPlane1, oproxyPlane1)
Dim oproxyPlane2 As WorkPlaneProxy
compOcc2.CreateGeometryProxy(oPlane2, oproxyPlane2)

Dim oConstraint As FlushConstraint
oConstraint = oAsmCompDef.Constraints.AddFlushConstraint(oproxyPlane1, oproxyPlane2, 0) 'add constraints in sub sub assembly




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

Post to forums  

Technology Administrators


Autodesk Design & Make Report