Need routine to clean drawings

Need routine to clean drawings

loftpc
Contributor Contributor
1,620 Views
16 Replies
Message 1 of 17

Need routine to clean drawings

loftpc
Contributor
Contributor

I am looking for some help in creating a lisp routine to clean up a large number of individual drawings. I am trying to create a circle "c" of 30 from a specific point, then trim "tr" any tangent/arc if it is outside of the circle (select line or arc if it is outside) , then erase the circle when done. This would save a number keystrokes over the hundreds of drawings to be cleaned up. Thanks in advance for the help!

 

@BushW has edited your subject line for clarity: circle/trim lisp routine

0 Likes
Accepted solutions (1)
1,621 Views
16 Replies
Replies (16)
Message 2 of 17

jmartt
Collaborator
Collaborator

I'd imagine that the LISP routine would be pretty easy. But I dunno how to do that. I wanted to say, though, that 1.) I've had good luck with posting things like this on the LISP forum: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

 

...And 2.) This may not be a viable option for you, but if I had to do something like this, I'd make a block with a hatched circle or donut of a color that the plot style is at 0 screening and place that circle/donut where you want it, effectively masking the linework.

 

 

0 Likes
Message 3 of 17

odoshi
Collaborator
Collaborator

Sounds like a modified version of EXTRIM (?)

 

I wrote an app that did something similar in .NET, but I think stringing a CIRCLE command, pickpoint, and EXTRIM command together might be simpler in LISP.

 

Regards,

Mike

 

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
0 Likes
Message 4 of 17

odoshi
Collaborator
Collaborator

(DEFUN C:COOKIE()

(SETQ PTCENTER (GETPOINT "CIRCLE CENTER POINT: "))
(COMMAND "CIRCLE" PTCENTER 30)
(SETQ CIRC (ENTLAST))
(if
(COND
(ETRIM)
(T (LOAD "extrim.lsp" "") ETRIM)
)
(ETRIM CIRC PTCENTER)
)

(PRINC)
)

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
Message 5 of 17

loftpc
Contributor
Contributor

Extrim not a good routine for this as it goes around the circle looking for lines/arcs to trim .. takes forever. I am a novice and do not know the programming procedures but I believe if I could load the circle "c" command, ask for a pt to draw a 30' radius from, then load the trim "tr" command and be able to trim to the circle it would give me what I'm looking for. Being able to erase the circle after selecting the last line/arc to trim would also be quite useful.  Thanks, Chip

0 Likes
Message 6 of 17

BushW
Alumni
Alumni

Hello @loftpc

 

I see that you are visiting as a new member to the AutoCAD Civil 3D forum. Welcome to the Autodesk Community!

 

Best Regards,

Wendell




Wendell Bush
Civil Infrastructure Technical Support Specialist
0 Likes
Message 7 of 17

awkeller88
Advocate
Advocate

I found this a while ago. Won't work with your circle (asks for a polyline). But should get you most of the way there.

;Required Express tools
;OutSide Contour Delete with Extrim
(defun C:OCD (  / en ss lst ssall bbox)
(vl-load-com)
  (if (and (setq en (car(entsel "\nSelect contour (polyline): ")))
           (wcmatch (cdr(assoc 0 (entget en))) "*POLYLINE"))
    (progn
      (setq bbox (ACET-ENT-GEOMEXTENTS en))
      (setq bbox (mapcar '(lambda(x)(trans x 0 1)) bbox))
      (setq lst (ACET-GEOM-OBJECT-POINT-LIST en 1e-3))
      (ACET-SS-ZOOM-EXTENTS (ACET-LIST-TO-SS (list en)))
      (command "_.Zoom" "0.95x")
      (if (null etrim)(load "extrim.lsp"))
      (etrim en (polar
                  (car bbox)
                  (angle (car bbox)(cadr bbox))
                  (* (distance (car bbox)(cadr bbox)) 1.1)))
      (if (and
            (setq ss (ssget "_CP" lst))
            (setq ssall (ssget "_X" (list (assoc 410 (entget en)))))
           )
        (progn
          (setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
          (foreach e1 lst (ssdel e1 ssall))
          (ACET-SS-ENTDEL ssall)
          )
        )
      )
    )
  )
(princ "\nType OCD")

 

~Andy

0 Likes
Message 8 of 17

AllenJessup
Mentor
Mentor

If you need a polyline. Draw a Donut instead of a Circle.

Allen Jessup
CAD Manager - Designer
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.

EESignature

Message 9 of 17

loftpc
Contributor
Contributor

Thanks for the suggestions but I'm really just looking to combine circle (with a radius), trim and erase commands into one lsp routine. Drawing a polyline, donut or using extrim is not giving me the solutions I need. Again, thanks for the advice though.

0 Likes
Message 10 of 17

AllenJessup
Mentor
Mentor

Just curiosity. But. Why wouldn't a Donut work?

Allen Jessup
CAD Manager - Designer
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.

EESignature

0 Likes
Message 11 of 17

AllenJessup
Mentor
Mentor

OK. You asked for help in writing a lisp. Do you need help or do you need someone to write it for you?

When you say " trim "tr" any tangent/arc if it is outside of the circle" do you mean you want to trim anything that crosses the circle and leave what remains inside the circle? Do you only want to trim lines and arcs or anything that crosses the circle? Do you want to erase anything that is outside the circle but does not cross it?

 

Basically you're dealing with 2 commands. The Circle command and the Trim command. Bearing in mind that you can erase from within the trim command.

 

For the Circle command you'll need the center point and radius, which you have already determined.

For the trim command I would select the circle by using Last. I would determine coordinates for a close fence just outside the circle to trim with and then use the eRase option in the Trim command to delete the circle. The easiest way to get coordinates for the fence is to draw it with a polyline and get the coordinates from the verticis.

Allen Jessup
CAD Manager - Designer
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.

EESignature

0 Likes
Message 12 of 17

odoshi
Collaborator
Collaborator

@AllenJessup Right on. Just use a 100 sided polygon. Plenty of vertices to pass to a fence list.

 

Anyways, the Honda Fit is free...the Lam is gonna cost $$. Smiley Tongue

 

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
Message 13 of 17

BushW
Alumni
Alumni

Hello @loftpc

 

I was following up to see if @odoshi@awkeller88 and @AllenJessup resolve your issue with the great suggestions? If so, please reward the post that worked with an ‘Accepted as Solution’ and also mark a post or posts as Accepted Solution(s) that resolved the issue or answered your question so, other Community members may benefit and thank you for doing so, and I’m here to help.

 

Best Regards,

Wendell




Wendell Bush
Civil Infrastructure Technical Support Specialist
0 Likes
Message 14 of 17

loftpc
Contributor
Contributor

Reposted a request on the AutoLisp forum and got a solution that worked as needed. Thanks to those that helped! Chip

 

 

 

Message 15 of 17

BushW
Alumni
Alumni

@loftpc

 

That's great! Can you provide the link that solved your post from the other forum? Thanks

 

Best Regards,

Wendell




Wendell Bush
Civil Infrastructure Technical Support Specialist
0 Likes
Message 16 of 17

AllenJessup
Mentor
Mentor
Accepted solution

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-lisp-routine-help/m-p/7491833#M3...

 

Allen Jessup
CAD Manager - Designer
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.

EESignature

Message 17 of 17

BushW
Alumni
Alumni

Thanks Allen




Wendell Bush
Civil Infrastructure Technical Support Specialist
0 Likes