Divide closed object into equals parts with gap

Divide closed object into equals parts with gap

40901305
Explorer Explorer
2,830 Views
14 Replies
Message 1 of 15

Divide closed object into equals parts with gap

40901305
Explorer
Explorer

Hi everyone, I'm new to AutoLisp and started using those few days ago which I found helping a lot to my work.

This Lisp I found on the internet can do part of my work. However I need to leave a gap between every sections after dividing. Please advise me on this.

Thanks so much.

0 Likes
2,831 Views
14 Replies
Replies (14)
Message 2 of 15

hak_vz
Advisor
Advisor

You should give more details how would you like gapes to be created. This code has been written by @Kent1Cooper so it would be fair that to let him make adjustments.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 15

40901305
Explorer
Explorer

Thanks hak_vz, I meaned after division, between sections which were divided, there are gaps that seperate them. Sorry @Kent1Cooper, please feel free to help me out with this. I'm appreciated with many thanks.

0 Likes
Message 4 of 15

Udo_Huebner
Mentor
Mentor

You can do this manually using the command _LENGTHEN. An then you can do it in the lisp macro as well.

Modify the function subdiv and add a lengthen command.

 

 

 (defun subdiv (obj brks)
 
    (repeat brks
     (command "_.break" obj (setq pt (trans (vlax-curve-getPointAtDist obj seclen) 0 1)) "@" ); end command
      ; create a -1 gap on the initial entity
      (command "_.Lengthen" "_delta" -1 (list obj pt) "")
      (setq obj (entlast))
    ); end repeat
  ); end defun - subdiv

 

 

 

Gruß Udo Hübner (CAD-Huebner)
0 Likes
Message 5 of 15

40901305
Explorer
Explorer

Thanks a lot Udo, I just tested with your additional code, work well while dividing line and spline. However when using for closed object, when using the code it seems not work very well, and can not work on circle also. Maybe needing some more adjustment.

0 Likes
Message 6 of 15

Udo_Huebner
Mentor
Mentor

Yes, it was just an idea of how to solve it, not the complete solution for every situation.

The case of circles, ellipses and closed splines is not completely handled by my code change.
This is because the gap is currently being added to the part that was cut off from the beginning of the object. So the length of the last segment remains unchanged so far. I don't know if this is a problem for you.

You still have to explain in more detail how the gap should be designed. So there is still much room for improvement.

 

 

 

Gruß Udo Hübner (CAD-Huebner)
0 Likes
Message 7 of 15

40901305
Explorer
Explorer

Thanks Udo for explanation, I just did an example as attachment. When dividing closed object, also create a gap at the cut point. I have to deal with around 350 closed objects so one by one is frustrating. That's why I'm looking for a lisp that let me choose multiple closed object and when I hit enter, automatically divide by 2 and add 2 gaps.  The one written by Kent Cooper help me out with automatic dividing.

0 Likes
Message 8 of 15

Udo_Huebner
Mentor
Mentor

Is the gap size fixed or do you prefer to ask for the gap? 

 

 

Gruß Udo Hübner (CAD-Huebner)
0 Likes
Message 9 of 15

40901305
Explorer
Explorer

Dear Udo, could you please help me to make it ask for the gap at first. Thanks so much

0 Likes
Message 10 of 15

Udo_Huebner
Mentor
Mentor
  • if the Objects are closed, do you expect the first gap on the start point or elsewhere?
  • And whats about multi select objects?
  • what AutoCAD version you are using? The error handler contains (command..) that have to be rewritten in newer versions. See http://help.autodesk.com/view/OARX/2021/DEU/?guid=GUID-620E034A-9151-427F-B6F5-B360D14DA925
  • I cannot imagine the real sense of this action. In general, I would avoid breaking objects only for visual reasons. You can place circular blocks with wipeouts instead on every breakpoint.
  • Please explain your intention.

 

Gruß Udo Hübner (CAD-Huebner)
0 Likes
Message 11 of 15

john.uhden
Mentor
Mentor

Well, not circular blocks with wipeouts but multi-sided polygons will work.

John F. Uhden

0 Likes
Message 12 of 15

40901305
Explorer
Explorer

Dear Udo, I'm using AutoCAD 2020 and doing a project relating to laser cutting. Making gaps remains my pieces on the board and not fall out after cut. I'm adjusting my project frequently for best fitting so needed for making gaps again and again, that's why I need applying on multiple objects. 

For example: I divide a circle in to two equal curve, between them are 2 gaps that I can adjust.

0 Likes
Message 13 of 15

john.uhden
Mentor
Mentor

This is eerily similar to the Stripe.lsp I recently submitted with the difference that the gap length can be specified only approximately.  It will have to be computed using the remains of a whole (integer) number of pen-downs.

With that, you can try figuring it out yourself.  It's much more satisfying than just grabbing someone else's cooked and served code.  That's probably why I like cooking; the recipes I find are only a guide as to what ingredients might want to be included.  Yeah, okay, chicken is chicken but scallions are not shallots.  And if you want to get more volume out of your au poivre sauce, go ahead and mix it into some Knorr brown gravy mix.  And be brazen and throw in some sliced mushrooms, and of course the slightly sauteed chopped shallots.  I used to use the Knorr mushroom gravy mix, but I can't find it anymore here around the Jersey Shore.

John F. Uhden

0 Likes
Message 14 of 15

Udo_Huebner
Mentor
Mentor

Ok I upload an updated version. Feel free to test. I am off for the next 2 days.

 

Gruß Udo Hübner (CAD-Huebner)
0 Likes
Message 15 of 15

devitg
Advisor
Advisor

@40901305  What about if you would started your post with a clear explanation , and some sample.dwg 

 

as @john.uhden  state, making meal , need recipe,  cooking tools,  a range or an oven, and mainly WHAT you want to meal. 

 

 

0 Likes