Jump to content

changing all text of 1 layer to another


Recommended Posts

Posted

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.

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • Acad_2010_user_NL

    13

  • Tharwat

    10

  • piscopatos

    5

  • alanjt

    4

Popular Days

Top Posters In This Topic

Posted Images

Posted

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"

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

 

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

Posted

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:

Posted
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

Posted

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

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

 

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

Posted
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 :oops: what do i need to adjust???

 

thanks!

Posted
Its allmost perfect only thing is the color of the new layers i whant them color 2 :oops: 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)
)

Posted
thnx for the effort alan
Does that mean it worked or not?
Posted

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.

Posted

I think I've done enough. Remember, I do this for free and on my time. You should give programming a shot.

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