Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cut circle

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
carlos_m_gil_p
5529 Views, 7 Replies

Cut circle

Hello how are you.


Could someone help me with a lisp.
To cut a circle.


Attached is an example to understand me.

 

Excuse my English, I only speak Spanish.

 

Thank you.


AutoCAD 2025
Visual Studio Code 1.87.2
AutoCAD AutoLISP Extension 1.6.2

7 REPLIES 7
Message 2 of 8

Here is a link to a Break routine. You may need to register (which is free)

 

https://www.theswamp.org/index.php?topic=10370.0

 

BreakAll.png

Message 3 of 8

Since the Lines are only there as references, to determine the breaking points, and are not part of either the starting conditions or the final result, I assume you would like to do this without having to draw the Lines, if possible [greg.battin's suggested link appears to require the Lines to be there].  I think this could be done with an AutoLisp routine, by calculation, without actually drawing the Lines.  I can't work on that right now, but I will look at it soon, if someone else doesn't come up with something first.

Kent Cooper, AIA
Message 4 of 8
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

....  I think this could be done with an AutoLisp routine, by calculation, without actually drawing the Lines.  ....


I managed to work something up -- not as involved as I originally thought it might be, because a Break command can take points that are not on the object being broken, so it can just use the Polyline vertices.

 

It could use the usual *error* handling, etc., and it could be enhanced to verify that the User actually picked a Circle and a closed Polyline, and even that the Circle is actually inside the Polyline, and so on.  But for now, if you can ensure the correct selections yourself, in limited testing [I tried both LW and 3D Polylines, and Circles in and not in the current Coordinate System], it seems to work:

 

(defun C:BCinP ; = Break Circle INside Polyline
  (/ getpt crv ctr pl osm n)
  (defun getpt (par)
    (trans (vlax-curve-getPointAtParam pl par) 0 1)
  ); defun
  (setq crv (car (entsel "\nSelect Circle to be Broken: ")))
  (redraw crv 3); highlight
  (setq
    ctr (cdr (assoc 10 (entget crv)))
    pl (car (entsel "\nSelect surrounding Polyline: "))
    osm (getvar 'osmode)
  ); setq
  (setvar 'osmode 0)
  (command "_.ucs" "_object" crv); to draw Arc in first Break
  (command ; can't single-point Break a Circle; take piece out and fill in:
    "_.break" crv (getpt 0) (getpt 1); resulting Arc has same entity name
    "_.arc"
      (trans (vlax-curve-getEndPoint crv) 0 1)
      "_c" "0,0"
      (trans (vlax-curve-getStartPoint crv) 0 1)
    "_.chprop" "_last" "" "_layer" (cdr (assoc 8 (entget crv))) ""
  ); command
  (repeat (- (setq n (fix (vlax-curve-getEndParam pl))) 2)
    (command "_.break"
      (ssname (ssget "_F" (list '(0 0 0) (getpt (setq n (1- n)))) '((0 . "ARC"))) 0)
        ; remaining Arc [whether = to 'crv' depends on direction Polyline was drawn]
      (getpt n) (getpt n); single-point
    ); command
  ); repeat
  (command "_.ucs" "_previous")
  (setvar 'osmode osm)
  (princ)
); defun
(vl-load-com)
Kent Cooper, AIA
Message 5 of 8

 

Hello greg.battin thanks for your help, but it did not work for me.

 

Hello how are you Kent1Cooper.
Thanks for your help too.
The function works well in the top view.
You could modify it to work in any view.
(Note: The cuts will always be in the top view.)
What I want is to select objects in any view but cut the circle as if he were in the top view.

 

Thank you.


AutoCAD 2025
Visual Studio Code 1.87.2
AutoCAD AutoLISP Extension 1.6.2

Message 6 of 8


@carlos_m_gil_p wrote:

....
The function works well in the top view.
You could modify it to work in any view.
(Note: The cuts will always be in the top view.)
What I want is to select objects in any view but cut the circle as if he were in the top view.

....


Since the Fence selection for finding the remaining Arc depends on the view direction, I think the only viable way to do that is to go into top view [Plan view in the WCS] for the operation, and then back if you were starting elsewhere.  Try this modification of the core of it:

 

....
  (setvar 'osmode 0)
  (command
    "_.ucs" "_object" crv ; to draw Arc in first Break
    "_.plan" "_world"
    ; can't single-point Break a Circle; take piece out and fill in:
    "_.break" crv (getpt 0) (getpt 1); resulting Arc has same entity name
    "_.arc"
      (trans (vlax-curve-getEndPoint crv) 0 1)
      "_c" "0,0"
      (trans (vlax-curve-getStartPoint crv) 0 1)
    "_.chprop" "_last" "" "_layer" (cdr (assoc 8 (entget crv))) ""
  ); command
  (repeat (- (setq n (fix (vlax-curve-getEndParam pl))) 2)
    (command "_.break"
      (ssname (ssget "_F" (list '(0 0 0) (getpt (setq n (1- n)))) '((0 . "ARC"))) 0)
        ; remaining Arc [whether = to 'crv' depends on direction Polyline was drawn]
      (getpt n) (getpt n); single-point
    ); command
  ); repeat
  (command "_.zoom" "_previous" "_.ucs" "_previous")
  (setvar 'osmode osm)
....

Make sure UCSFOLLOW is turned off, so that it doesn't go into the Circle's plan view when it changes the UCS [that can be built into the code if you normally have UCSFOLLOW turned on].

 

Kent Cooper, AIA
Message 7 of 8

Thanks so much for the help.
It works very well.
Greetings.


AutoCAD 2025
Visual Studio Code 1.87.2
AutoCAD AutoLISP Extension 1.6.2

Message 8 of 8

Hello @Kent1Cooper how are you.
Sorry to bother you, but I wanted to ask you, if you can check the lisp.
It is that when the polyline is missing a section, the last arc is not cut.
I also wanted to ask you if it is possible for the drawn bows to be colored.
Anyway, I am attaching an example.
Beforehand thank you very much.

Excuse my English, I only speak Spanish.


AutoCAD 2025
Visual Studio Code 1.87.2
AutoCAD AutoLISP Extension 1.6.2

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost