Hi, anyone can help to see if my attach lisp can add sort of counter that how many dimensions, leader and multileaders have been move to layer "dimension"...Thanks.
Solved! Go to Solution.
Hope you do not mind with this small modification .
;;this lisp is to Automatic select all Dimension,Leader & Multileaders to layer DIMENSION (defun c:dime (/ ss) ; for Dimensions and Leaders to Dims Layer (command "_.chprop" (setq ss (ssget "X" '((0 . "DIMENSION,LEADER,MULTILEADER")))) "" "_LAyer" "Dimension" "" ) ; end command (princ (strcat "Number of entitties that moved to Layer Dimension is :" "< " (itoa (sslength ss)) " >" ) ) (princ) ) ; end defun
Tharwat
(Defun c:dime (/ ss lst i nme var) (foreach useri (setq lst '(("LEADER" . "1")( "MULTILEADER". "2") ("DIMENSION" . "3"))) (setvar (strcat "useri" (cdr useri)) 0)) (if (setq ss (ssget "_X" '((0 . "DIMENSION,LEADER,MULTILEADER")(8 . "~Dimension")))) (progn (repeat (setq i (sslength ss)) (setq ent (entget (ssname ss (setq i (1- i))))) (entmod (subst '(8 . "Dimension") (assoc 8 ent) ent)) (setq Nme (assoc (cdr (assoc 0 ent)) lst) var (cdr nme)) (set (setq x (read (car nme)))(1+ (getvar (strcat "useri" var)))) (setvar (strcat "useri" var) (eval x)) ) (textscr) (foreach nms lst (print (car nms))(print (getvar (strcat "useri" (cdr nms)))) ) ) (princ "\nNone Found:")) (princ) )
Hope you guys arent using the system variables useri1 to 3.
Thanks alot for the lisp modification. Greatly appreciate it... There is one thing i notice..those text that done by leader command, it won't be automatic change to dimension layer. Is there still any possible way to modify the lisp abit so that even the text apper near to leader still can be change to dimension layer?
sure, but think we might need to re-write the code though. the first one its a bit messy, at frist iwanted to pass a variable name for the counter but ended up using useri* variable . hence this line is unnecessary
(setvar (strcat "useri" (cdr useri)) 0));<--- silly me
post a sample drawing, wo we can have a good look how your mleader/mtext is structured
Hi, i have attach along a sample drawing...In "Drawing A", i use multileader ,while in "Drawing B", i use the normal leader..
Thus,when i use the lisp, it will automatic move all dimension to a layer including the leader and multileader except the mtext created by normal leader. Please advise.
Try this
(Defun c:dime (/ toler tolr ss lst i nme var ll ur) (defun Toler (val lst) (mapcar '(lambda (o)(+ val o)) lst)) (foreach useri (setq lst '(("LEADER" . "USERI1") ("MULTILEADER" . "USERI2") ("DIMENSION" . "USERI3") ("MTEXT" . "USERI4"))) (setvar (cdr useri) 0)) (setq tolr (cond ((getreal (strcat "\nEnter Distance from Leader Line <" (rtos (setq tolr (cond ( tolr ) ( 1.0 ))) 2 2) ">: "))) ( tolr ) ) ) (if (setq ss (ssget "_X" '((0 . "DIMENSION,LEADER,MULTILEADER") (8 . "~Dimension")))) (progn (repeat (setq i (sslength ss)) (setq ent (entget (ssname ss (setq i (1- i))))) (entmod (subst '(8 . "Dimension") (assoc 8 ent) ent)) (setq Nme (assoc (cdr (assoc 0 ent)) lst) var (cdr nme)) (set (setq x (read (car nme))) (1+ (getvar var))) (setvar var (eval x)) (if (equal (car Nme) "LEADER") (progn (vla-getboundingbox (vlax-ename->vla-object (ssname ss i)) 'll 'ur) (if (setq subsel (ssget "_C" (trans (toler (* tolr -1) (vlax-safearray->list ll)) 0 1) (trans (toler tolr (vlax-safearray->list ur)) 0 1) '((0 . "MTEXT")))) (progn (vla-put-layer (vlax-ename->vla-object (ssname subsel 0)) "Dimension") (setvar 'useri4 (1+ (getvar 'Useri4))) ) ) ) ) ) (textscr) (foreach nms lst (print (car nms)) (print (getvar (cdr nms))) ) ) (princ "\nNone Found:")) (princ) )
Im not sure how your other drawings will look, so a prompt for "Enter Distance Leader Line" is necessary for this to work. the default value is 1.0
Hope your drawing is as organized as your sample
Cheers
Well, just give it a try just now..It works fine and good.. Thanks..By the way, may i know where to see if our "Distance leader line" is weather having a value of 1???
Anyway, i also got give a testing by typing another integer, it also works fine too..
@lai wrote:Well, just give it a try just now..It works fine and good.. Thanks..By the way, may i know where to see if our "Distance leader line" is weather having a value of 1???
its a safety precaution, if by somehow the MTEXT is more than jsut 1.0 units away from the leader point it wont be selected. but on your sample i think is all well and good as you are using 1.0. to know the distance between the mtext and the leader point use distance command or dist pick the endpoint where the mtext is located and the "ins" point of the mtext.
by the way change this line:
(setq subsel (ssget "_C"
(trans (toler (* tolr -1) (vlax-safearray->list ll)) 0 1)
(trans (toler tolr (vlax-safearray->list ur)) 0 1)
'((0 . "MTEXT"))))to:
(setq subsel (ssget "_C"
(trans (toler (* tolr -1) (vlax-safearray->list ll)) 0 1)
(trans (toler tolr (vlax-safearray->list ur)) 0 1)
'((0 . "MTEXT")(8 . "~Dimension"))))
Otherewise it will give you an incorrect number of MTEXT moved to dimension layer.
We could add a prompt for target layer if needed. but i guess you can figure it out on your own.
Glad it helps
Cheers
hi, recently i notice that the below lisp somehow it show me some error as below :-
Command: acdl
Enter Distance from Leader Line <1.00>:
; error: bad SSGET list
I not sure what happen...sometimes it works find..but sometime not...i try to do testing too..Copy all the entities in the drawing,copy to a new drawing, then run the lisp again and it work fine but yet, sometimes not...Any idea?
@lai wrote:hi, recently i notice that the below lisp somehow it show me some error as below :-
Command: acdl
Enter Distance from Leader Line <1.00>:
; error: bad SSGET list
I not sure what happen...sometimes it works find..but sometime not...i try to do testing too..Copy all the entities in the drawing,copy to a new drawing, then run the lisp again and it work fine but yet, sometimes not...Any idea?
I see, my guess is there area objects included in the selection outside of the current tab
so try changing this
(setq ss (ssget "_X"
'((0 . "DIMENSION,LEADER,MULTILEADER")
(8 . "~Dimension"))))
to this
(setq ss (ssget "_X"
(list '(0 . "DIMENSION,LEADER,MULTILEADER")
'(8 . "~Dimension")(cons 410 (getvar 'Ctab)))))
That will avoid selecting the objects not on the current viewport
Also you may need to add this
(setvar 'Osmode 0) to avoid snapping ot objects while inside (ssget "_C")
Remember this lisp code were writen wihtout r error trapping subs.
HTH
Hi pbejse,
Thanks for the feedback..Anyway, i just give it a try as what you given,but still got the error..I have attach along the sample drawing for you to test and my newly modify lisp according to your advise.
@lai wrote:Hi pbejse,
Thanks for the feedback..Anyway, i just give it a try as what you given,but still got the error..I have attach along the sample drawing for you to test and my newly modify lisp according to your advise.
There lies the problem.... 😉
'((0 . "MTEXT")(8."~Dimension"));<---- no space between 8."
to
'((0 . "MTEXT")(8 . "~Dimension"))
so....
(setq subsel (ssget "_C"
(trans (toler (* tolr -1) (vlax-safearray->list ll)) 0 1)
(trans (toler tolr (vlax-safearray->list ur)) 0 1)
'((0 . "MTEXT")(8 . "~Dimension"))))
and put the osmode outside of the sget
(Defun c:tot (/ toler tolr ss lst i nme var ll ur)
(setq om (getvar 'Osmode))(setvar 'Osmode 0)
.......
......
(princ "\nNone Found:"))
(setvar 'Osmode om)
(princ)
)
HTH
hi, thanks for the advise....I have attach here the final lisp for future user ease to get it....