Jump to content

Recommended Posts

Posted

A mystery..

I'll continue to keep my eyes peeled to differences as I do more of them.

Thanks nonetheless

  • 5 weeks later...
  • Replies 34
  • Created
  • Last Reply

Top Posters In This Topic

  • SteveK

    15

  • Lee Mac

    14

  • brawleyman

    4

  • fuqua

    2

Top Posters In This Topic

Posted Images

Posted

Hey!

 

Is there a way to make this code just select everything on a particular layer (which will always be a circle) and trim everything on the inside of it?

Posted
Have you tried using EXTRIM for this task?

 

Yes, but it only works with one object at a time. I want to be able to begin the LISP routine and it automatically select all circles on the Trim layer then trim everything inside of those selected circles at once. I don't want to have to click inside of the circle to note inside or outside. Just trim everything on the inside automatically of all the circles.

Posted

The Extrim can be very easily modified to accept a selection set :)

 

Not sure whether to post it though as it is copyrighted Autodesk stuff :unsure:

Posted

I looked at extrim, and while it would be possible to modify it for a selection set how would you tell it to trim inside every circle? It'd have to be a specialized circle extrim.

But yeah, maybe you'd get in trouble...

Posted

You would redefine Extrim as a sub-function, accepting a single entity (as it currently does) and a point. And remove the prompts for such.

 

Then, define a function that collects a SelSet (by whichever means you like), and calls the sub-function. :)

Posted

That's clever and would be quite a generally handy tool.

 

And a good way of avoiding all those acet- functions; there's no help file on any of them.

Posted

Just thinking out loud, I wonder if there is a way of doin it without editing extrim something like:

 

(setq ss (ssget "_X" '((0 . "CIRCLE")(8 . "Trim"))))

(foreach circle (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
 (setq ctr (cdr (assoc 10 (entget circle))))

 (command "EXTRIM" [color=Red]circle[/color] "" ctr "")

 )

This doesn't work cause I don't know how to make extrim select the circle (in red)...

 

 

 

Alternatively, maybe create a fence just inside each circle and just use standard trim.

 

I hope someone can help you brawleyman, it'd be good to know.

Posted

I think editing the EXTRIM is the only way here - as EXTRIM in itself would need to be called:

 

(c:EXTRIM)

 

At which point it takes precedence over any previous function running.

Posted
You would redefine Extrim as a sub-function, accepting a single entity (as it currently does) and a point. And remove the prompts for such.

 

Then, define a function that collects a SelSet (by whichever means you like), and calls the sub-function. :)

 

That is kind of what I was thinking, using it as a sub function and basically make it repeat itself for all the circles or even set it up so that you can just click on the type of typical object you want it to trim within like a square, circle, or something else even within a block. I think that a lisp routine like this would be pretty useful for some people.

 

The only problem is that I have no idea how or where to start with a lisp like that. All I can do in LISP is create some basic stuff where I fuse together several commands, kind of like in a macro, to accomplish what I need.

 

LeeMac, you know what I mean. You have seen some of the primitive lisps I have made...not pretty. :huh:

Posted

I know exactly what you mean, and yes I have successfully modifed it and it works great (if not somewhat slowly) on my machine.

 

However, I am reluctant to post it due to a possible copyright infringement. :cry:

  • 2 weeks later...
Posted
Yes, but it only works with one object at a time. I want to be able to begin the LISP routine and it automatically select all circles on the Trim layer then trim everything inside of those selected circles at once. I don't want to have to click inside of the circle to note inside or outside. Just trim everything on the inside automatically of all the circles.

Sorry this is a bit delayed Brawleyman: If Lee hasn't already provided you with a better solution this is a dodgy way that just draws a square on the four quadrants of every circle and trims them. It will likely miss some lines (because it's a square not a circle) but if it's what you want you can always add more points around the circle to increase its' effectiveness.

 

Problems due to its dodginess include (but are not limited too):

- If the circles are not in the current view it probably won't trim them.

- If the lines cross on the quadrants it probably won't trim correctly (you might want to subtract a bit from the rad value to deal with this; I don't know what precision you are dealing with)

(defun c:TrCircs (/ ss
          ctr rad pt1 pt2 pt3 pt4)
 (If (setq ss (ssget "_X" '((0 . "CIRCLE")(8 . "Trim"))))
   (Progn
     (foreach circle (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
   (setq ctr (cdr (assoc 10 (entget circle)))
         rad (cdr (assoc 40 (entget circle))))
   (setq pt1 (list (- (car ctr) rad) (cadr ctr) (caddr ctr))
         pt2 (list (car ctr) (+ (cadr ctr) rad) (caddr ctr))
         pt3 (list (+ (car ctr) rad) (cadr ctr) (caddr ctr))
         pt4 (list (car ctr) (- (cadr ctr) rad) (caddr ctr))
         )
   (command "TRIM" circle "" "F" pt1 pt2 pt3 pt4 pt1 "" "")
   )
     )(Princ "\nNo Circles on \"Trim\" Layer were found.\n"))
 (princ)
 )

Posted
Sorry this is a bit delayed Brawleyman: If Lee hasn't already provided you with a better solution this is a dodgy way that just draws a square on the four quadrants of every circle and trims them. It will likely miss some lines (because it's a square not a circle) but if it's what you want you can always add more points around the circle to increase its' effectiveness.

 

Problems due to its dodginess include (but are not limited too):

- If the circles are not in the current view it probably won't trim them.

- If the lines cross on the quadrants it probably won't trim correctly (you might want to subtract a bit from the rad value to deal with this; I don't know what precision you are dealing with)

(defun c:TrCircs (/ ss
          ctr rad pt1 pt2 pt3 pt4)
 (If (setq ss (ssget "_X" '((0 . "CIRCLE")(8 . "Trim"))))
   (Progn
     (foreach circle (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
   (setq ctr (cdr (assoc 10 (entget circle)))
         rad (cdr (assoc 40 (entget circle))))
   (setq pt1 (list (- (car ctr) rad) (cadr ctr) (caddr ctr))
         pt2 (list (car ctr) (+ (cadr ctr) rad) (caddr ctr))
         pt3 (list (+ (car ctr) rad) (cadr ctr) (caddr ctr))
         pt4 (list (car ctr) (- (cadr ctr) rad) (caddr ctr))
         )
   (command "TRIM" circle "" "F" pt1 pt2 pt3 pt4 pt1 "" "")
   )
     )(Princ "\nNo Circles on \"Trim\" Layer were found.\n"))
 (princ)
 )

 

Thanks Steve1! That is almost what I need. I just need it to trim at 45 degree angles as well and I need it to trim everything on the inside of the circle instead of the outside. Could you please revise your code to do that? Sorry I am not good enough with lisp to just change what you have a little to make it work.

 

Also, can it be revised to work on that layer within blocks?

Posted
Thanks Steve1! That is almost what I need. I just need it to trim at 45 degree angles as well and I need it to trim everything on the inside of the circle instead of the outside. Could you please revise your code to do that? Sorry I am not good enough with lisp to just change what you have a little to make it work.

 

Also, can it be revised to work on that layer within blocks?

 

Ok I've adjusted it slightly:

(defun c:TrCircs (/ ss
          ctr rad count pts)
 (If (setq ss (ssget "_X" '((0 . "CIRCLE")(8 . "Trim"))))
   (Progn
     (foreach circle (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
   (setq ctr (cdr (assoc 10 (entget circle)))
         rad (cdr (assoc 40 (entget circle)))
         rad (- rad[b][color=Red] (/ rad 10.)[/color][/b]))

   ; Create list of points around the inside circumference of circle
   (setq count 0)
   (while (/= count 365)
     (setq pts (cons (polar ctr (* count (/ pi 180)) rad) pts)
       count (+ count 5))
     )

   (command "TRIM" circle "" "F")
   (foreach x pts (command "_non" x))
   (command "" "")

   )
     )(Princ "\nNo Circles on \"Trim\" Layer were found.\n"))
 (princ)
 )

You might have to experiment with the highlighted number. This number determines the distance in from each circles' circumference. (eg. at the moment it makes the fence a tenth of whatever the radius of the current circle is). I've noticed that if we draw a fence inside each circle too close to the circles' circumference trim will not work properly (ie it'll probably trim lines outside the circle - what you were getting).

 

As for trimming inside blocks, unfortunately trim doesn't work on blocks so yeah you'd need to find another method.

 

Hope it works for you,

 

steve

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...