Jump to content

Recommended Posts

Posted

As a way to standardise our cad files I need a way to change the text layer based on its height. any help appreciated.

Posted

You can use QSELECT to select all text-objects with a specific height, then you can manually change the layer.

Posted

That is the way I have been doing it previously but I wanted to know if there was a way to do this in a LISP routine so I simply type the command and it fixes it all?

Posted

Do you want help with writing a lisp routine, or were you hoping someone would provide it for you?

Posted

Step through a selection set of text and use 'cond' to match text height with predefined criteria and place on appropriate layer.

Posted

I have moved your thread to the Lisp forum, hope you find what you seek here.

Posted
As a way to standardise our cad files I need a way to change the text layer based on its height. any help appreciated.

 

This will you get to started,

just change on desired layer names

 

 
(defun C:CHLT(/ *error* elist en exist ss)
 ;;error trapping function
   (defun *error* (msg)
   (cond ((or (not msg)
       (member msg '("console break" "Function cancelled" "quit / exit abort"))
       )
   )
  ((princ (strcat "\nError: " msg)))
  )
     (command "._layerp")
     (command "._undo" "_end")
     (command)
   (princ)
   )
;;local defun
 (defun _get_layer_name (height)
   (cond ((zerop height) nil)
  ((equal 1.0 height) "Layer1")
  ((equal 1.5 height) "Layer2")
  ((equal 2.0 height) "Layer3")
  ((equal 2.5 height) "Layer4")
  ;;etc...
  );<--change  on appropriate layers here    
   )

(prompt "\n  >>  Select text objects to apply the layers by text height  >>")
(if (setq ss (ssget ":L" (list (cons 0 "TEXT"))))
 (progn
   (command "._undo" "_begin")
   (command "._layer" "_on" "*" "")
   (while
     (setq en (ssname ss 0))
     (setq elist (entget en))
     (if (setq exist  (_get_layer_name (cdr (assoc 40 elist))))
(progn
       (setq elist (subst (cons 8 exist)(assoc 8 elist) elist))
       (entmod elist)
(entupd en)
)
)
     (ssdel en ss))
   )
 )

   (*error* nil)
   (princ)
   )

 

~'J'~

Posted

Or maybe for a total global change:

 [b][color=BLACK]([/color][/b]setq th '[b][color=FUCHSIA]([/color][/b][b][color=NAVY]([/color][/b]1.0 . [color=#2f4f4f]"LAYER1"[/color][b][color=NAVY])[/color][/b]
            [b][color=NAVY]([/color][/b]2.0 . [color=#2f4f4f]"LAYER2"[/color][b][color=NAVY])[/color][/b]
            [b][color=NAVY]([/color][/b]3.0 . [color=#2f4f4f]"LAYER3"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 [b][color=BLACK]([/color][/b]foreach g th
    [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"*TEXT"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 40 [b][color=RED]([/color][/b]car g[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]progn
          [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]not [b][color=BLUE]([/color][/b]tblsearch [color=#2f4f4f]"LAYER"[/color] [b][color=RED]([/color][/b]cdr g[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
              [b][color=GREEN]([/color][/b]command [color=#2f4f4f]"_.LAYER"[/color] [color=#2f4f4f]"_N"[/color] [b][color=BLUE]([/color][/b]cdr g[b][color=BLUE])[/color][/b] [color=#2f4f4f]""[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
          [b][color=MAROON]([/color][/b]command [color=#2f4f4f]"_.CHPROP"[/color] ss [color=#2f4f4f]""[/color] [color=#2f4f4f]"_LA"[/color] [b][color=GREEN]([/color][/b]cdr g[b][color=GREEN])[/color][/b] [color=#2f4f4f]""[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

-David

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