Requesting Change in lisp Code

Requesting Change in lisp Code

Anonymous
Not applicable
788 Views
2 Replies
Message 1 of 3

Requesting Change in lisp Code

Anonymous
Not applicable

Dear Group Members,

 

Below lisp code is asking for block selection every time, instead of Block name by user input. Can you please change the lisp code from block selection to the Required block name as input?.

 

Thanks a lot in advance.

(defun C:BSPS (/ os ce bm blk ent obj ppt dst ept ref len ipt par slp ang)
(command "_.undo" "_be")
(setq os (getvar "osmode")
ce (getvar "cmdecho")
bm (getvar "blipmode")
blk ""
);;setq
(if (not bk)(setq bk ""))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(while (not (setq ent (entsel "\nSelect object near reference end: "))))
(while
(and
(not (tblsearch "block" blk))
(not (findfile (strcat blk ".dwg")))
);;and
(setq blk (cdr (assoc 2 (entget (car (entsel "\n Select Block"))))))
(if (> blk "")(setq bk blk)(setq blk bk)) 
);;while
(while (setq obj (car ent)
ppt (osnap (cadr ent) "nea")
dst (getdist "\nDistance to Block Insertion: ")
ept (vlax-curve-getEndPoint obj)
ref (vlax-curve-getDistAtPoint obj ppt)
len (vlax-curve-getDistAtPoint obj ept)
);;setq
(if (> ref (/ len 2.0))
(setq dst (- len dst))
);;setq
(setq ipt (vlax-curve-getPointAtDist obj dst)
par (vlax-curve-getParamAtPoint obj ipt)
slp (vlax-curve-getFirstDeriv obj par)
ang (atan (/ (cadr slp)(car slp)))
);;setq
(entmake
(list
'(0 . "INSERT")
(cons 2 blk)
(cons 10 ipt)
(cons 50 ang)
);;list
);;entmake
)
(princ)
) 

 

Accepted solutions (1)
789 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

@Anonymous wrote:

Dear Group Members,

 

Below lisp code is asking for block selection every time, instead of Block name by user input. Can you please change the lisp code from block selection to the Required block name as input?.

 

Thanks a lot in advance.

(defun C:BSPS (/ os ce bm blk ent obj ppt dst ept ref len ipt par slp ang)
(command "_.undo" "_be")
(setq os (getvar "osmode")
ce (getvar "cmdecho")
bm (getvar "blipmode")
blk ""
);;setq
(if (not bk)(setq bk ""))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(while (not (setq ent (entsel "\nSelect object near reference end: "))))
(while
(and
(not (tblsearch "block" blk))
(not (findfile (strcat blk ".dwg")))
);;and
(setq blk (getstring T "\nBlock name: ")) ;(cdr (assoc 2 (entget (car (entsel "\n Select Block"))))))
(if (> blk "")(setq bk blk)(setq blk bk)) 
);;while
(while (setq obj (car ent)
ppt (osnap (cadr ent) "nea")
dst (getdist "\nDistance to Block Insertion: ")
ept (vlax-curve-getEndPoint obj)
ref (vlax-curve-getDistAtPoint obj ppt)
len (vlax-curve-getDistAtPoint obj ept)
);;setq
(if (> ref (/ len 2.0))
(setq dst (- len dst))
);;setq
(setq ipt (vlax-curve-getPointAtDist obj dst)
par (vlax-curve-getParamAtPoint obj ipt)
slp (vlax-curve-getFirstDeriv obj par)
ang (atan (/ (cadr slp)(car slp)))
);;setq
(entmake
(list
'(0 . "INSERT")
(cons 2 blk)
(cons 10 ipt)
(cons 50 ang)
);;list
);;entmake
)
(princ)
) 

 


 

 
Message 3 of 3

Anonymous
Not applicable

Thanks a lot Sir. You saved lot of hours to me.