Jump to content

Change chamfer results to the current layer?


BrianTFC

Recommended Posts

Hi All

 

Does any one have a Lisp routine to turn the diagonal line that chamfer creates to the current layer instead of the original layer of the lines? I would appreciate any help.

 

 

Thanks

Brian

Link to comment
Share on other sites

(defun c:Chamfer2 (/ ent)
 (setq ent (entlast))
 (command "_.chamfer")
 (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command PAUSE))
 (if (not (equal ent (setq ent (entlast))))
   (entmod (list (cons 8 (getvar 'CLAYER)) (cons -1 ent)))
 )
 (princ)
)

Link to comment
Share on other sites

But when chamfering a Polyline object while Trimmode variable is set to zero, there may be more than one object as the result of CHAMFER.

For this case alanjt's nice code can be edited to:

 

(defun c:Chamfer2 (/ ent)
(setq ent (entlast))
(command "_.chamfer")
(while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command PAUSE))
[b][color=purple](while (setq ent (entnext ent))
 [/color][/b](entmod (list (cons 8 (getvar 'CLAYER)) (cons -1 ent)))
)
(princ)
)

Link to comment
Share on other sites

Be careful when 'entlast' is an Attribute Block or Polyline. ;)

I checked Polyline and it doesn't cause any error on VERTEX and SEQUEND objects, but changes ATTRIB objects. So the code can be edited to this one:

(defun c:Chamfer2 (/ ent)
(setq ent (entlast))
(command "_.chamfer")
(while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command PAUSE))
(while (setq ent (entnext ent))
 (or
  (member (cdr (assoc 0 (entget ent))) '("ATTRIB" "VERTEX" "SEQUEND"))
  (entmod (list (cons 8 (getvar 'CLAYER)) (cons -1 ent)))
 ) 
)
(princ)
)

Link to comment
Share on other sites

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...