Constrain geometry proxy of IManagedComponents

Constrain geometry proxy of IManagedComponents

Mathias_CompC
Enthusiast Enthusiast
775 Views
8 Replies
Message 1 of 9

Constrain geometry proxy of IManagedComponents

Mathias_CompC
Enthusiast
Enthusiast

I've tried to be clever all by myself, and I've currently hit a wall where I believe I know what I should do, but I hope that I am wrong, or that someone else has a better solution.

 

I've tried to upgrade how we work with our dynamic iLogic components, Content Center parts, and other semi-automated design documents. In this process I've crated a library folder in the Vault, and in that I have saved out sub-assemblies for telescopic slides. These have been working like a charm, and now, I'm trying to replace the telescopic rails in a dynamic model with the following piece of code.

ThisAssembly.BeginManage("TelRails")
	Dim RailLeft = Components.Add("Rail, Left", "iAssemblies\XXX-" & RailLength & ".iam")
	Dim RailRight = Components.Add("Rail, Right", "iAssemblies\XXX-" & RailLength & ".iam")
	RailLeft.Occurrence.Flexible = True
	RailRight.Occurrence.Flexible = True
ThisAssembly.EndManage("TelRails")

 

Previously I had all possible rails in the assembly and hid/deleted the ones that were not applicable.

Now I want to work smarter and become better at anything Inventor so I tried Constraints.AddByiMates, and that worked great.
Then, I needed to offset said Constraint, and "the game is on". If I want to add a "proper" Mate I want to use Constraints.AddMate("oOcc", "WorkFeature1", "oOcc2", "WorkFeature2"). but the SubAss that is the telescopic rail doesn't have "WorkFeature1", so instead i tried oCompArg to it's subPart "innerSlide", and the named Surface("InnerFrontFace"). 

This, sort of works, but I really don't want to name every surface i eventually want to put a constraint to.

Is it possible to "easily" grab a GeometryProxy from an iMate?

Or even better, have I missed a simple way to make this that is "standard" when adding constraints to "not-origin" of placed components?

 

0 Likes
Accepted solutions (1)
776 Views
8 Replies
Replies (8)
Message 2 of 9

Cadkunde.nl
Collaborator
Collaborator

First I would suggest to use origin planes. If you replace the components, it's ideal that they all have same origin and orientation.

 

But if that can't be done:

If all components have the same orientation (X-Y-Z) You could find the first workplane that is parallel with either X, Y or Z

 

Something like:

Dim odoc as Assemblydocument = Thisdoc.document

Dim owps as Workplanes = odoc.componentdefintion.workplanes

if owps.count > 3 Then

For i = 4 to owps.count

If owps.item(i).plane.isparallelTo(owps.item(1)) = True Then 'workplane items 1,2,3 are always X, Y, Z

msgbox("plane " & i & "is parallel")

End If

Next

end if

 

This is a method that is not really stable, but it finds user created workplanes without its name.

 

I'll run a test with imates and see if I can get it to offset.

 

 

 

0 Likes
Message 3 of 9

Cadkunde.nl
Collaborator
Collaborator

If I try Constraints.addbyimates() I see no option to add an offset

Also without ilogic snippet:

 

Dim odoc As AssemblyDocument = ThisDoc.Document
odoc.ComponentDefinition.iMateResults.AddByTwoiMates()

There is no way to add offset.

Only when creating an iMate it is possible to add an offset and use that as resting position

 

Dim odoc As AssemblyDocument = ThisDoc.Document
odoc.ComponentDefinition.iMateDefinitions.AddFlushiMateDefinition()

 

I'm not very good with iMates, rarely use them.

But my guess is the information need to be stored inside them, in the assembly you just snap them. (no additional angle, direction or offset)

0 Likes
Message 4 of 9

Mathias_CompC
Enthusiast
Enthusiast

Using the origins is certainly viable, if I only wanted to use it to locate the placed component.

As I mentioned, possilby unclear, the component I'm "playing" with is a telescopic rail, and the component.Occ is set Flexible. 


I tried creating Workplanes in the placed components assembly and using these for the constraints, however these workplanes are never "consumed" and will therefore always be visible in new instances of said component. This is a very unwanted behaviour that I've disregarded entirely after I realised that I can't control future assemblies visibility settings.

 

I look forward to your reply, and if I can help you help me in any way, just tell me. 🙂

0 Likes
Message 5 of 9

Mathias_CompC
Enthusiast
Enthusiast

I'll try to explain this a bit further with an image of a Telescopic Slide in question.

the slide is an assembly consisting of three parts.

All parts are constrained "heightwise" to the assembly's Origin plane.
The outer part is also Mate-Constrained to an assembly Origin plane in the other two directions.
The middle and inner part are "thickness-wise" constrained to each other and the outer part.

Inner part, Red1 is Min-Max flush-constrained to Outer Blue4.

Middle part is Symmetrically constrained to the other two.

kXlsuIaYrZ.png

Manually I have no issues identifying these faces. But I am Human and have biases that the API does not. I want two "sets" of constraints, one for what is attached to the inner part(red). And one for the Outer part(blue). 

 

I'm not sure this helped at all, but perhaps 🙂

0 Likes
Message 6 of 9

Cadkunde.nl
Collaborator
Collaborator

I think what you describe with visibility only happens when the workplanes are visible inside the part.

If you turn off visibility in the assembly, you turn off visibility of a 'proxy' and not the real workplane.

 

If you create the workplane in the script, then you should set visibility off afterwards.

0 Likes
Message 7 of 9

Mathias_CompC
Enthusiast
Enthusiast

I'm probably confused.

Any unconsumed work feature in a part or assembly will follow the visibility settings of the context that they are used in.

I would love to hear what you mean with the visibility of "the real work plane".

 

If I could create the work planes in the script it we be a total non-issue, but that requires me to already reference the GeometryProxy to create said work plain on the correct place.

Did I miss you solution?  

0 Likes
Message 8 of 9

A.Acheson
Mentor
Mentor
Accepted solution

You could used named faces/edges (entities) in your parts and use proxies of these objects in the constraints. What I would do in this scenario is to constrain as normal the faces without imates as that might bring in too much complications. Then use capture tool to captures the constraints between parts/assemblies etc. You will notice where the proxy faces are located. This is where you will need to replace with your named entity to automatically identify which faces you want included in your constraint. Example of this process here

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 9 of 9

Mathias_CompC
Enthusiast
Enthusiast

That functionality of "Capture Current State(Constraints.Add)" has completely passed my attention.

That is perfect!

Thank you! =D

0 Likes