Jump to content

Need Help on creating LISP for Chamfering between Line and ARC


NKK

Recommended Posts

I am working on a Master planning project which has around 500 plots, now I want to chamfer the edge of all my plot and most my my combination contains of an Arc and a line, see attached images for sample.

 

Can anyone please help me !

01.PNG

02.PNG

03.PNG

04.PNG

05.PNG

Link to comment
Share on other sites

Should the chamfer distance along the arc be an arc length or a tangent (e.g. straight line) length?

 

How about polylines, are the line and arc segments part of a polyline or just simple line and arc segments?

Edited by kirby
added clarification
Link to comment
Share on other sites

This lisp basically does what you want.  https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/chamfer-2-0/td-p/10822529

 

(defun c:chd (/ spm dc ss s1 s2 pins c pc1 pc2)
  (vl-load-com)
  (setq spm (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
  (setq dc (getreal "\nEnter Chamfer distance: "))
  (setq ss (ssget))
  (if (= (sslength ss) 2)
    (progn
      (setq s1 (vlax-ename->vla-object (ssname ss 0)))
      (setq s2 (vlax-ename->vla-object (ssname ss 1)))
      (setq pin (vla-intersectwith s1 s2 acextendnone))
      (setq cc (vla-addcircle spm pin dc))
      (setq pc1  (vla-intersectwith cc s1 acextendnone))
      (setq pc2  (vla-intersectwith cc s2 acextendnone))
      (vla-erase cc)
      (vla-addline spm pc1 pc2)
      (setq line (entlast))
      ;trim from line ?
    )
    (prompt "\nOnly pick two objects")
  )
)

 

  • Like 1
Link to comment
Share on other sites

Hi mhupp,

 

Thanks for the LISP, but it doesn't trim the edges after the Chamfer has been created and also it doesn't remember the last chamfer unit inserted, so I have to insert the number each time I run the command and also can you make it work for Pline aswell.

 

Thanks.

Link to comment
Share on other sites

2 hours ago, NKK said:

it doesn't trim the edges after the Chamfer has been created and also it doesn't remember the last chamfer unit inserted

 

Yeah couldn't figure out how to trim in time. will remember last input defaults to 5 the first time.

 

(defun c:chd (/ spm dia ss s1 s2 cen cir pc1 pc2 line)
  (vl-load-com)
  (setq spm (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
  (setq dia (vlax-ldata-get "cir" "dia")) 	;checks for ldata and sets the variable
  (if (= dia nil) (setq dia "5")) 			    ;first time running it will default to value 5
  (if (= "" (setq a (getstring (strcat "\nIngresa Dia [" dia "]: ")))) 
    (setq a dia)                            ;if you hit enter it will set a to dia value else override it to what you input
  )
  (vlax-ldata-put "cir" "dia" a)            ;Saves value to drawing
  (setq ss (ssget))
  (if (= (sslength ss) 2)
    (progn
      (setq s1 (vlax-ename->vla-object (ssname ss 0))
            s2 (vlax-ename->vla-object (ssname ss 1))
            cen (vlax-safearray->list(vlax-variant-value (vla-intersectwith s1 s2 acextendnone)))
            cir (vla-addcircle spm cen dia)
            pc1  (vla-intersectwith cir s1 acextendnone)
            pc2  (vla-intersectwith cir s2 acextendnone)
      )
      (vla-erase cir)
      (setq line (vla-addline spm pc1 pc2))    
      (command "_.Trim" line "")
      (command (list (ssname SS 1) cen))
      (command (list (ssname SS 0) cen))
      (command "")
    )
    (prompt "\nOnly pick two objects")
  )
  (princ)
)

 

 

 

 

Edited by mhupp
Link to comment
Share on other sites

17 minutes ago, NKK said:

Thanks, it is showing error when chamfering ARC with line, it's working fine when Arc is drawn as a Polyline.

 

Can you share what the error says? Are they connected/touching like your example? everything working over here.

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