Run Part-Rule - when this part has 5 constraints in assembly - Trigger

Run Part-Rule - when this part has 5 constraints in assembly - Trigger

jaapschreuder
Contributor Contributor
371 Views
4 Replies
Message 1 of 5

Run Part-Rule - when this part has 5 constraints in assembly - Trigger

jaapschreuder
Contributor
Contributor

Currently I'm working on a code that works when a number of constrains are created to a part.

 

Small introduction;

 

I have a part, that will be part of a library of parts that I will commonly use, that will be always used in an assembly environment.
So I have an assembly, where there is one part (product) that is always there, and the product is always different.
The parts I'm adding will be always constrained almost the same way - and need 5 constraints to be fully fixed.

If these 5 constrains are placed (assembly level) - I need the rule to be triggered (Part level). The rule in the part is working OK - and if there are 5 constrains in the assembly active the rule will proceed with another rule.
(In the rule the length of the part is defined to 'best standard' and will also change/deviate the offset to the outside of the part. It sort of middles the position of the part to the best fit.

 

The picture will make this more clear I hope

example.jpg

For I  may have many of these parts in the assembly, I do not want to run the rules of all the parts every time there is a change.

 

I want the rule to be triggered when;
* every time the 5th constrained is placed
* every time a model parameter changes (part level)

Problems I encounter at the moment - the rules I've written on part level will not be runt when the changes are done on assembly level.

 

Can you help me find a work around, so I can be sure my parts are all 'up to date' when I'm done constraining them and more important - that they-re updated after a change or modification on my Part(product) where they're all depending on?

 

 

 

 

guess.

0 Likes
372 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

That's a fairly complex problem.  To trigger a rule by counting how many constraints are added to a specific component within an assembly, would require either working with local rule within the assembly, or an Add-in.  One of the local rules could create an Event Handler to watch catches every time you place a constraint, then checks the constraints count for both components involved.  That rule would be triggered to run either at New Document, or After Open Document, so it can listen for those events.  The second rule would have to delete that Event Handler, so it doesn't keep running and stacking up handlers in the background.

Perhaps a simpler way might just be to create a local assembly rule that is triggred to run on Any Model Parameter Change, because every time you create a constraint, it automatically creates model parameters to go with it.  The rule would specify the component you want to watch and gets its constrains count.  If count is < (less than) 5, it does nothing.  If count = 5, it does what you want.  If count > 5, does nothing (because it has already done its thing, and you don't want it to continue firing.)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

jaapschreuder
Contributor
Contributor

I've got the constraint count covert on part level; as well as the change parameter trigger;

but it only works within the part; Constraining the part and manually trigger the rule to check the constraints will result in an OK part.

looping thru each part to search for this rule could be a solution, but doesn't look like a neat one at this point. (but if it works, who cares)
Issue with it; if my part(product) changes (linked to excel) I do not make any parameter changes and therefore the rules would not run.
If I was the only person to work with this it could work, but I want it to be as foolproof as possible.

 

If only the parts would run their rules if their being changed on assembly level...

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

How is the Part file linked to an Excel spreadsheet if no Parameter changes take place when there are changes in its linked Excel spreadsheet?  Usually when someone 'links' a part to an Excel spreadsheet, the only way to change the specified Parameters is then by the Excel spreadsheet.  Then when the values of those parameters changes in the Excel spreadsheet, and spreadsheet is saved, it instantly changes those linked Paremeters within the Part file.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

jaapschreuder
Contributor
Contributor

I tried if this triggers a rule; it doesn't

 

The part that is linked to the excel sheet contains the coordinates of the part. These coordinates are workpoints in the part.
By these workpoints there is a 3d-sketch where a sweep is created.

 

Since this is an part update, I don't think it can trigger a rule on assembly level.

 

I hope you'll understand.

0 Likes