Jump to content

Routine request - Set some layers to specific linetype


Recommended Posts

Posted

Hi!

 

I have many layers i would like to see them forced to specific linetypes.

Let say;

Layers.............Linetypes

M-N-INC-25--->Hidden-25

M-N-INC-32--->Hidden-32

 

I would like to bind this function to a button and each time i click the button it set the layers to the specific linetypes above.. and when i click button one more time it set all these layers back to "By Layer" ...

if its not possible i could use 2 button instead but its less impressive :)

 

Thanks in advance.

Posted

used as a learning experience... minimal error checking and testing

Edit as necessary

BTW... you can't set a layer's linetype to Bylayer, I used Continuous

(defun c:test (/ laylist)
 (setq laylist (list "M-N-INC-25" "M-N-INC-32"))
 (if
   (eq (getvar "useri1") 0)
    (progn
      (foreach    ln laylist
    (if
      (tblsearch "ltype" (strcat "Hidden-" (substr ln (- (strlen ln) 1))))
        (command "layer" "l" (strcat "Hidden-" (substr ln (- (strlen ln) 1))) ln "")
      (alert (strcat "Load linetype " (strcat "Hidden-" (substr ln (- (strlen ln) 1))) " first"))
      );if
            )                       ;foreach
      (setvar "useri1" 1)
    )                    ;progn
    (progn
      (foreach    ln laylist
    (command "layer" "l" "continuous" ln "")
      )                             ;foreach
      (setvar "useri1" 0)
    )                    ;progn
 )                    ;if
)                    ;defun

Posted

Wow it work really good :)

 

I would like to understand few things on how it work.

i am still at the "hello world" state.

 

(tblsearch "ltype" (strcat "Hidden-" (substr ln (- (strlen ln) 1))))

(command "layer" "l" (strcat "Hidden-" (substr ln (- (strlen ln) 1))) ln "")

(alert (strcat "Load linetype " (strcat "Hidden-" (substr ln (- (strlen ln) 1))) " first"))

 

First line, i beleive you are gathering ltype into the *.lin file...

one line 2 you force the layer to be on a linetype...

line 3 (alert) no idea...

 

Can you please tell me how it work i dont see how you call Hidden-25 line type..

 

and i would like to add more layer/Ltype in the future

 

Let say

M-N-MAIN-100 --to ltype--- CENTER-100

 

how can i do that?

Posted

First line > takes the layer's name, strips all but the last 2 characters and tacks it on to Hidden-, then searches to see if the linetype Hidden-nn is loaded. If it is loaded it sets the layer's linetype to Hidden-nn (line 2). If the linetype is not loaded it skips to line 3 and gives you an alert to load it first.

 

As far as the rest, I suppose it could done, but maybe layer states would be easier.

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