piscopatos Posted August 19, 2010 Posted August 19, 2010 hello everyone and thanx in advance to those who helps as Acad_2010_user_NL specified it in the first quote he wrote, cant we modify this command (sssetfirst nil(ssget "_x" '((0 . "TEXT,MTEXT")(8 . "Layer 4")))) as, after it selected the text it should also create a layer named as layer-text and put those selected texts into the new layer. Quote
Acad_2010_user_NL Posted August 19, 2010 Author Posted August 19, 2010 I was (trying) to write a script this is what i wrote and it works BUT not flawless: -LAYER NEW "Level 1-text" (sssetfirst nil(ssget "_x" '((0 . "TEXT,MTEXT")(8 . "Level 1")))) chprop p la "level 1-text" Quote
Tharwat Posted August 19, 2010 Posted August 19, 2010 hello everyone and thanx in advance to those who helpsas Acad_2010_user_NL specified it in the first quote he wrote, cant we modify this command (sssetfirst nil(ssget "_x" '((0 . "TEXT,MTEXT")(8 . "Layer 4")))) as, after it selected the text it should also create a layer named as layer-text and put those selected texts into the new layer. First the selected texts are belong to the Layer that specified earlier in codes. So if you want to select a text and create a Layer according to the text contints , that needs a seperate routine. What you think ? Tharwat Quote
Acad_2010_user_NL Posted August 19, 2010 Author Posted August 19, 2010 im learning sinds yesterday so i dont know very much but the flaw in my script is that if (sssetfirst nil(ssget "_x" '((0 . "TEXT,MTEXT")(8 . "Layer 4")))) gives nil it stops. So im trying to create a circuit when it gives the value nil it skips the chprop command and goes to the next line. but i dont know how to (yet) :wink: Quote
piscopatos Posted August 19, 2010 Posted August 19, 2010 First the selected texts are belong to the Layer that specified earlier in codes.So if you want to select a text and create a Layer according to the text contints , that needs a seperate routine. What you think ? Tharwat tht's why i asked for help because i dunno how to write lisps yet. thnx Quote
alanjt Posted August 19, 2010 Posted August 19, 2010 Just for fun... (defun c:ToText (/ la name lk ss new) ;; Move all *Text and *Leaders to a text layer, matching primary layer (eg. ALAN -> ALAN-TEXT) ;; Includes objects on locked layers ;; Layer created if doesn't exist (also takes on color of primary layer) ;; Alan J. Thompson, 08.19.10 (vl-load-com) (vlax-for l (setq la (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (or (wcmatch (strcase (setq name (vla-get-name l))) "*-TEXT,*$*") (if (setq ss (ssget "_X" (list '(0 . "*LEADER,*TEXT") (cons 8 name)))) (progn (and (setq lk (eq :vlax-true (vla-get-lock l))) (vla-put-lock l :vlax-false)) (or (tblsearch "LAYER" (setq new (strcat name "-TEXT"))) (vla-put-color (vla-add la new) (vla-get-color l)) ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (vl-catch-all-apply (function vla-put-layer) (list x new)) ) (vla-delete ss) (and lk (vla-put-lock l :vlax-true)) ) ) ) ) (princ) ) Quote
Tharwat Posted August 19, 2010 Posted August 19, 2010 hello everyone and thanx in advance to those who helpsas Acad_2010_user_NL specified it in the first quote he wrote, cant we modify this command (sssetfirst nil(ssget "_x" '((0 . "TEXT,MTEXT")(8 . "Layer 4")))) as, after it selected the text it should also create a layer named as layer-text and put those selected texts into the new layer. here is routine to create layer according to text String. (defun c:Tlay (/ a b c d ) (prompt "Select a Text : ") (if (setq a (ssget "+.:S" '((0 . "TEXT,MTEXT")))) (progn (setq b (ssname a 0)) (setq c (entget b) d (cdr(assoc 1 c)) )) (princ) ) (command "_.-layer" "_make" d "" "") (princ) ) Regards Tharwat Quote
Acad_2010_user_NL Posted August 19, 2010 Author Posted August 19, 2010 Just for fun... (defun c:ToText (/ la name lk ss new) ;; Move all *Text and *Leaders to a text layer, matching primary layer (eg. ALAN -> ALAN-TEXT) ;; Includes objects on locked layers ;; Layer created if doesn't exist (also takes on color of primary layer) ;; Alan J. Thompson, 08.19.10 (vl-load-com) (vlax-for l (setq la (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (or (wcmatch (strcase (setq name (vla-get-name l))) "*-TEXT,*$*") (if (setq ss (ssget "_X" (list '(0 . "*LEADER,*TEXT") (cons 8 name)))) (progn (and (setq lk (eq :vlax-true (vla-get-lock l))) (vla-put-lock l :vlax-false)) (or (tblsearch "LAYER" (setq new (strcat name "-TEXT"))) (vla-put-color (vla-add la new) (vla-get-color l)) ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (vl-catch-all-apply (function vla-put-layer) (list x new)) ) (vla-delete ss) (and lk (vla-put-lock l :vlax-true)) ) ) ) ) (princ) ) Its allmost perfect only thing is the color of the new layers i whant them color 2 what do i need to adjust??? thanks! Quote
alanjt Posted August 19, 2010 Posted August 19, 2010 Its allmost perfect only thing is the color of the new layers i whant them color 2 what do i need to adjust??? thanks! Marked in red... (defun c:ToText (/ la name lk ss new) ;; Move all *Text and *Leaders to a text layer, matching primary layer (eg. ALAN -> ALAN-TEXT) ;; Includes objects on locked layers ;; Layer created if doesn't exist and set with color of 2 ;; Alan J. Thompson, 08.19.10 (vl-load-com) (vlax-for l (setq la (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (or (wcmatch (strcase (setq name (vla-get-name l))) "*-TEXT,*$*") (if (setq ss (ssget "_X" (list '(0 . "*LEADER,*TEXT") (cons 8 name)))) (progn (and (setq lk (eq :vlax-true (vla-get-lock l))) (vla-put-lock l :vlax-false)) (or (tblsearch "LAYER" (setq new (strcat name "-TEXT"))) [color=red](vla-put-color (vla-add la new) 2)[/color] ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (vl-catch-all-apply (function vla-put-layer) (list x new)) ) (vla-delete ss) (and lk (vla-put-lock l :vlax-true)) ) ) ) ) (princ) ) Quote
alanjt Posted August 19, 2010 Posted August 19, 2010 thnx for the effort alanDoes that mean it worked or not? Quote
piscopatos Posted August 19, 2010 Posted August 19, 2010 it worked thnx but it can be modified. as u see with this code it adds -text string to every layers which has text in it. how about modifying it as adding the -text strigns to the layers which user chooses, you know like move command, u type move in the command line and it lets you to chose the things tht you want to move. type totext in the command line and chose something on the screen that belong to the layer which u want to creat -text layer from. Quote
alanjt Posted August 19, 2010 Posted August 19, 2010 I think I've done enough. Remember, I do this for free and on my time. You should give programming a shot. Quote
Recommended Posts
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.