Cadline Community

Return to the search page

Blog Luke Davenport's Blog

(ref: ld-170713)

iLogic – Optimize Loop Length In Sketch

Hello iLogic fans – here is another subject that has been percolating for a while. 

What if I am producing sketches of belt layouts (or similar) where I need to obtain a certain loop length but the geometry is complex enough that the loop length is not a simple 1+1+1 = 3 calculation?

Well as I’ve discovered, the usual method for this is more than a little frustrating! Let’s see - Measure the length of the loop, adjust a dimension, measure the length of the loop, adjust the dimension, measure, adjust, measure, adjust, chop chop, dig dig….. Even if you don’t need a high level of accuracy this is a headache!

Surely we can do a little better than that?

Well it’s not too hard to write a simple optimization loop with iLogic. I’ve written one that allows you to pick the parameter you want to adjust (you can only vary one parameter at a time of course!), enter the target length for the loop in the sketch and then it will modify the chosen parameter until you hit the target length, accurate to 3 d.p.

A couple of things to be aware of:

1)      The iLogic code only works on the first sketch in the part – probably best to run it first before you start creating solid geometry.

2)      It will actually work based on ALL the lines in the sketch (except construction and centrelines) – whether they are in a loop or not.

3)      The code will run through 100 iterations, and if it can’t hit the target to 3 d.p. accuracy by that time it gives you a message to let you know.

Click on the picture at the top to see the video of this rule in action.

NOTES:

1)      As usual if you are copying and pasting the code make sure you don’t create any blank line gaps in the paste operation as this will cause an error.

2)      ALWAYS save the file before running the rule. If the geometry does something silly (and the automatic reset doesn’t work) then you won’t be able to hit undo 100 times to get it back.

And here’s the code in full. As always – let me know if you see any new uses for iLogic. Enjoy!

 


Leave a comment:

Note you must be logged in before you can post a comment.
Rate this Blog: