Modification for a LISP

Modification for a LISP

krishravi2000
Enthusiast Enthusiast
425 Views
1 Reply
Message 1 of 2

Modification for a LISP

krishravi2000
Enthusiast
Enthusiast

Hi guys,

I want slight modification in this LISP

if i gave the command "KK" the autoCAD asks 1st point then 2nd point at the end a cutline appears but i want a modification. When i give the command the cutline should also appear with a layer

Eg: if I have a Layer named "DETAIL" and if I give the command KK it should ask 1st point then 2nd point at the end a cutline appears that cutline should be in the layer of "DETAIL"

(defun c:KK (/ spt1 ept1 d1 ct1 d2 d3 d4 ang1 ang2 ang3 ang4 pt1 pt2 pt3 pt4) ;start of cut
;(setq sc (getvar "DIMSCALE"));REV 8-14-98
(setvar "cmdecho" 0)
(setq spt1(getpoint "\nFirst Cut Point: ")) ;spt1=start pt
(setq ept1(getpoint spt1 "\nSecond Cut Point: ")) ;ept=end pt
(setq d1 (distance spt1 ept1)) ;d1=dist start to end pt
(setq ct1 (/ 10 2)) ;ct1=1/2 scale factor
(setq ct1 (* 25.4 ct1))
(setq d2 (/ d1 3)) ;d2=1/3 of d1
(if (>= d2 ct1) ;if d2 is greater or = ct1
(progn ; then
(setq d3 (/ ct1 2)) ;d3=1/4 scale factor
(setq d2 (- (/ d1 2) d3)) ;d2=dist to start of cut
) ; end of progn
(setq d3 (/ d2 2)) ; if not d3=1/6 of d1
); end of if
(setq d4 (sqrt (+ (* d3 d3) (* d3 d3)))) ;d4=dist of cut ang
(setq ang1 (angle spt1 ept1)) ;ang1=ang of start to end pt
(setq ang2 (angle ept1 spt1)) ;ang2=ang of end to start pt
(setq ang3 (+ ang1 0.785398)) ;ang3=ang1+45 deg
(setq ang4 (+ ang3 3.92699)) ;ang4=ang3+225 deg
(setq pt1 (polar spt1 ang1 d2)) ;pt1=start pt of cut
(setq pt2 (polar pt1 ang3 d4)) ;pt2=45deg pt
(setq pt3 (polar pt2 ang4 (* 2 d3))) ;pt3=225deg pt
(setq pt4 (polar pt3 ang3 d4)) ;pt4=end pt of cut
(setq spt1 (polar spt1 ang2 d4)) ;spt1=add length to start pt
(setq ept1 (polar ept1 ang1 d4)) ;ept1=add length to end pt
(command ".pline" spt1 pt1 pt2 pt3 pt4 ept1 "") ;draw pline
(command "'redraw") ;clean up
(reset nil)
) ;end of cut

0 Likes
Accepted solutions (1)
426 Views
1 Reply
Reply (1)
Message 2 of 2

tramber
Advisor
Advisor
Accepted solution

Put that : 

 

(command "_change" (entlast) "" "_p" "_layer" "DETAIL" "")

 

Before the (command "redraw")

...should work if the layer exists !

(if(tblsearch "layer" "detail")(command "_change" (entlast) "" "_p" "_layer" "detail" ""))

In case you could not be sure 😎


EESignature