Jump to content

Lisp to chamfer two intersecting lines


Lee Chu Chu

Recommended Posts

Why not have a go at writing something yourself Cadtutor is not a I WANT I WANT service. We can help when you get stuck.

 

Well said Bigal :thumbsup:

 

Besides that , they don't even take a few seconds to reply to their own threads ( recent one HERE ) , and this conduct is really terrible and I don't respect it at all .:glare:

Link to comment
Share on other sites

AFAIK command .....

 

Afaik is not a valid command?????

 

Now that's good one right there, What hanhphuc meant was "As Far As I Know" .

 

If you want to chamfer, i suggest you play around with the "chamfer" command using a macro

Link to comment
Share on other sites

I know I can use the chamfer command in the commandline and explore options but the lisp I am trying to write is to be able to chamfer two intersecting lines while they are being drawn and while the lisp is active.

 

PS: I wasn't even joking about not knowing that AFAIK is an acronym.

Link to comment
Share on other sites

Now that's good one right there, What hanhphuc meant was "As Far As I Know" .

Thanks pBE for clarification :)

 

I know I can use the chamfer command in the commandline and explore options but the lisp I am trying to write is to be able to chamfer two intersecting lines while they are being drawn and while the lisp is active.

not sure you draw 2 lines separately or continuously? or you can draw a polyline first then chamfer with polyline option, all vertex will be chamfered

$0.02

Link to comment
Share on other sites

(defun c:test () 
(setq PT1 (getpoint))
(setq PT2 (getpoint PT1))
(command "line" PT1 PT2)
(command)
(setq obj1 (entget (entlast)))
(setq typeinfo1 (substr (cdr (assoc 0 obj1))1))
(setq layerinfo1 (substr (cdr (assoc 8 obj1))1))

(setq ent (car PT2))
(if (not ent)
	(princ "yay!")
)
(command "line" pause pause)
(command)
(setq obj2 (entget (entlast)))
(setq typeinfo2 (substr (cdr (assoc 0 obj2))1))
(setq layerinfo2 (substr (cdr (assoc 8 obj2))1))

(if (and (= typeinfo1 typeinfo2) (= layerinfo1 layerinfo2))
	(princ "\nit works\n")
)
(princ)
)

 

This is what I have at the moment for if I draw a line and it finds an existing line with the same layer I chamfer those two lines. Only problem is that I am struggling to program the part where it checks to see if that on the second point of my first drawn line, there is an existing line where it intersects with

Link to comment
Share on other sites

This is what I have at the moment for if I draw a line and it finds an existing line with the same layer I chamfer those two lines. Only problem is that I am struggling to program the part where it checks to see if that on the second point of my first drawn line, there is an existing line where it intersects with

 

it's good start you attempt coding yourself :thumbsup:

perhap like this?

(defun c:test (/ PT1 PT2 PT3 PT4 en ss1 ss2)
;;;hanhphuc 13.02.2015
;;;drawline with chamfer
 (mapcar 'setvar '(chamfera chamferb)
  '(5.0 5.0)) ;[color="red"] <--default chamfer value you can change here[/color]
 (prompt "\nDraw lines.. ")
 (if (and (setq PT1 (getpoint "\n1st line.."))
   (setq PT2 (getpoint PT1))
   (not(grdraw PT1 PT2 7 0))
   (setq PT3 (getpoint "\n2nd line"))
   (setq PT4 (getpoint PT3))
   ) ;_ end of and
   (progn
     (redraw)
     (setq en (mapcar ''((x) (entmakex (vl-list* '(0 . "LINE") (mapcar 'cons '(10 11) (eval (cons 'list x))))))
	       '((PT1 PT2) (PT3 PT4))
	       ) ;_ end of mapcar
    ) ;_ end of setq
    
   (foreach x '(ss1 ss2) (set x (ssadd)))
   (mapcar ''((a b) (ssadd a b)) en (list ss1 ss2))
   (vl-cmdf "_.chamfer" ss1 ss2)
   ) ;_ end of progn
 ) ;_ end of if
(princ)
) ;_ end of defun

Link to comment
Share on other sites

What does this program actually do? Because I already have a program that is a lot simpler than that to draw two lines and then chamfer them?

Link to comment
Share on other sites

What does this program actually do? Because I already have a program that is a lot simpler than that to draw two lines and then chamfer them?

 

Code was referred to post#7

It simply uses command chamfer to draw, not complicated.

 

If you do have code why not post earlier ? :?

 

or perhaps vla-intersectWith method is what you are looking for?

 

Cheers

Edited by hanhphuc
typo intersectwith & post#7
Link to comment
Share on other sites

Oh.. if you mean chamfer at 90,

If you attempt to code

then try draft and post the step if you do manually ,(ie: pseudo code)

Perhaps this may help others to attempt if you get stuck :)

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