Retaining constraints during a component replace

Retaining constraints during a component replace

keithjk
Advocate Advocate
2,709 Views
10 Replies
Message 1 of 11

Retaining constraints during a component replace

keithjk
Advocate
Advocate

I am not sure if this question should be in the standard Inventor forum, or here.  Since I do a lot of customization, and cannot figure out how to do this through standard Inventor commands, I am posting it here.

 

We have situations where our users need to replace a component with many constraints to it.  All of the constraints are work plane based with both the standard origin planes and user work planes being used.  Also, when doing the replacement, Part A and Part B always have the same work plane names and the vector of the work planes are always the same also.  

 

I guess if you could, think of replacing a shoe box with a larger or smaller shoe box.  Both shoe boxes have work planes named Box Top, Box Right Side, Box Left Side, etc.  The only difference is the size of the box.

 

It appears that Inventor doesn't care if the shape and work planes are the same when doing a replacement.  It seems Inventor has an issue with the size as we lose many of the constraints.  I also tried the demoting and promoting route, and that gets us in the right direction, but it is a lot of steps.

 

Again, I do lots of Inventor programming, and may be able to write code to do this but I do not want to reinvent the wheel.


Any suggestions?

 

 

 

 

0 Likes
2,710 Views
10 Replies
Replies (10)
Message 2 of 11

bshbsh
Collaborator
Collaborator

Yes, Inventor doesn't care about names or shapes, it uses internal ID numbers for geometric proxies of faces/edges/etc. If the Id of the replacing component, or the type of proxy doesn't match the original one, then the cpntraint will loose one of it's entities - permanently. This makes recovering nearly impossible, because all the information of the previous entity is lost. A way to prevent this is to use some code to do the component replace itself as well, and before the actual replace, store the necessary information of all related constraints traced back to your workplanes' names etc., then recreate those broken constraints with the stored names applied to the new component. Or just insert the new component without replacing the old one and modify the constraints to point to elements on the new component, then delete the old occurrance. This way nothing gets lost. I do this latter by hand occassionally too.

Size differences: as long as the replacement component is exactly the same (and by that I mean the internal structure, element IDs, etc.) or an ascendant of the old one (ia. a "save copy as" with just a few parameters changed), this shouldn't break contraints.

Message 3 of 11

keithjk
Advocate
Advocate

Thanks bshbsh,  I like the approach of just inserting new components and then deleting the old ones.  That sounds like it should be fairly straight forward.

0 Likes
Message 4 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi Keith,

 

There is a possibility to retain the constraints upon replacing components. A sample.zip is attached with this post to demonstrate the same.

 

Unzip and open "ConstraintTest.iam" assembly file, Run iLogic rule called "Replace component". After running the iLogic rule, HexaBolt is replaced by RoundBolt with retained constraints.

 

For further investigation, please provide non confidential files.

 

Please free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 11

keithjk
Advocate
Advocate

Hi Chandra,

 

Finally getting back to this project.  Thanks for your reply.

 

I have Inventor 2016 and it looks like your file was created by 2017 perhaps? 

 

Would you be able to give me an example in 2016 format or just post the iLogic code?

 

Thanks again....

 

Keith

0 Likes
Message 6 of 11

MechMachineMan
Advisor
Advisor

This is the only code located within the files attached:

 

SyntaxEditor Code Snippet

Try
    Component.Replace("HexBolt:1", ThisDoc.Path &"\RoundBolt.ipt", True)
Catch
    Component.Replace("RoundBolt:1", ThisDoc.Path &"\HexBolt.ipt", True)
End Try

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 7 of 11

keithjk
Advocate
Advocate

Thanks Justin.

0 Likes
Message 8 of 11

keithjk
Advocate
Advocate

Chandra,

 

Per bshbsh's reply, I think your solution works on some replacements but not in my case.  I am having the same problem as if I do a Component Replace through standard Inventor commands. 

 

I am going to try the route that bshbsh suggested.  I think with a little programming, that should work.

 

Keith

0 Likes
Message 9 of 11

MechMachineMan
Advisor
Advisor

Depending on what else the thing is constrained to, you might have a bit fun!

 

The way I would do it:

 

1. Add new copy of the part.

2. Iterate through the constraints that are attached to ORIG

3. Without adding a new constraint, change the entity referencing the ORIG to the entity of the same name on NEW.

4. Delete the old part.

 

You might have fun with this because to get the "same geometry on a different component", you will need to use proxies. @bshbsh had posted a useful snippet for doing this for the part. However, in your case, you also need to do a "pre-check/swap" in case the entities are of the same name.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 10 of 11

Anonymous
Not applicable

Please get familiar with imates it will make your life easier since you can have several parts model in different ways but when you assign imates to those parts it will know exactly how to constrain when used in a assembly. Use your imates when putting your assemblies together. (Tip when possible reuse models rather than recreating models of similar components just to make your life easier)

imates are located in the manage menu

Message 11 of 11

Kay_Rethmeier
Advocate
Advocate

Hey there,


there are three ways to replace:
1) replacing totally different parts with different ID's like bshbsh  described it with all negative aspects
2) Using the origin work planes, points, axis only (the Autodesk example), than you can exchange trees with nuts or washers!
3) Define and use iMates, if you are using very often same parts or copies of them

 

One of our customer was migrating from a different system. They are designing electronic components! At the early beginning the developed one master-chip, a black box. All chips are based on this one master ship. Because of this all chips contain the same IDs. Each chip can be replaced with each of it's genetic twins!!! 😉

 

Ciao
Kay

Cheers
Kay (Principal CAD-Consultant)
0 Likes