Jump to content

Recommended Posts

Posted

I have a lisp to change an object to what layer I need it to be on. The layer name, color and linetype I have figured out. The only thing is some layers will need a different lineweight rather than default. For an example layer (as below) the Ancillary layer is suppose to be at .40 for lineweight. Where or how do I need to put in my current lisp the specific lineweight? Thanks for any help.

(defun c:CLA ( / CLAYER SS) ;;Changes lines to the ANCILLARY layer
  (princ "\nPick objects to be changed to the ANCILLARY layer: ")
  (setq CLAYER (getvar "clayer"))
  (setq SS (ssget))
  (if SS(command ".layer" "make" "ANCILLARY" "c" "200" "ANCILLARY" 
     "ltype" "continuous" "ANCILLARY" "set" CLAYER ""
     ".change" SS "" "p" "layer" "ANCILLARY" "color" "bylayer" "lt" "bylayer"  "")
     (princ "\nNothing selected"))
  (princ))

Posted

You should be able to add in a line of code in the layer command you have existing when you are making your layer. Use "LW" "0.40" "Layer-Name".

 

I'm curious why are you using the change command instead of the options you get under the layer command?

 

I have a lisp to change an object to what layer I need it to be on. The layer name, color and linetype I have figured out. The only thing is some layers will need a different lineweight rather than default. For an example layer (as below) the Ancillary layer is suppose to be at .40 for lineweight. Where or how do I need to put in my current lisp the specific lineweight? Thanks for any help.

(defun c:CLA ( / CLAYER SS) ;;Changes lines to the ANCILLARY layer
  (princ "\nPick objects to be changed to the ANCILLARY layer: ")
  (setq CLAYER (getvar "clayer"))
  (setq SS (ssget))
  (if SS(command ".layer" "make" "ANCILLARY" "c" "200" "ANCILLARY" 
     "ltype" "continuous" "ANCILLARY" "set" CLAYER ""
     ".change" SS "" "p" "layer" "ANCILLARY" "color" "bylayer" "lt" "bylayer"  "")
     (princ "\nNothing selected"))
  (princ))

Posted

Here... :)

 

"ltype" "continuous" "ANCILLARY" [color="magenta"]"LWeight" "0.4" ""[/color] "set" .......

Posted
Here... :)

 

"ltype" "continuous" "ANCILLARY" [color="magenta"]"LWeight" "0.4" ""[/color] "set" .......

 

Sweet! Tharwat saves the day! Thanks again

Posted
Sweet! Tharwat saves the day! Thanks again

 

You are most welcome.

Posted
You should be able to add in a line of code in the layer command you have existing when you are making your layer. Use "LW" "0.40" "Layer-Name".

 

I'm curious why are you using the change command instead of the options you get under the layer command?

 

Just how I was trained I guess.

  • 5 years later...
Posted

And I have a question, how do I get LW of current layer, I've tried with 

lyr_lw(cdr (assoc 370 (tblsearch "layer" current_lyr)))

but just getting nil

Posted
1 hour ago, Tomislav said:

And I have a question, how do I get LW of current layer, I've tried with 

lyr_lw(cdr (assoc 370 (tblsearch "layer" current_lyr)))

but just getting nil

(vl-load-com)(vlax-get-property (vla-Item (vla-get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object))) (getvar 'clayer)) 'lineweight)

 

try this

Posted
5 minutes ago, exceed said:
(vl-load-com)(vlax-get-property (vla-Item (vla-get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object))) (getvar 'clayer)) 'lineweight)

 

try this

 thank you for fast response, it works!

I was trying something with vla-... also, but I'm not that good with activex

Posted (edited)
7 minutes ago, Tomislav said:

 thank you for fast response, it works!

I was trying something with vla-... also, but I'm not that good with activex


(cdr (assoc 370 (entget (tblobjname "layer" (getvar 'clayer)))))

 


or you can do with dxf list like this way

reason = cannot get the assoc 370 in tblsearch list

becasue that is not a whole list. that is symbol list.

 

like when you make entity by entmake, 

in example 

(setq a (entmake ~~~)) 

(princ a)

this list also not contain ename, so, (entmakex ~~) is better to control that with ename.

so, get ename by (tblobjname) is better in your case. i think

Edited by exceed
Posted

well, this two lines worked

    lyr_col(cdr (assoc 62 (tblsearch "layer" c_lyr))); Layer color
    lyr_lt(cdr (assoc 6 (tblsearch "layer" c_lyr))); Layer line type

 

and that's why i tried like so for LW, but like you said, it seems that LW must be done through tblobjname

Posted
1 minute ago, Tomislav said:

well, this two lines worked

    lyr_col(cdr (assoc 62 (tblsearch "layer" c_lyr))); Layer color
    lyr_lt(cdr (assoc 6 (tblsearch "layer" c_lyr))); Layer line type

 

and that's why i tried like so for LW, but like you said, it seems that LW must be done through tblobjname

Command: (tblsearch "layer" (getvar 'clayer))
((0 . "LAYER") (2 . "0") (70 . 0) (62 . 7) (6 . "Continuous"))

 

Command: (entget (tblobjname "layer" (getvar 'clayer)))
((-1 . <ENTITY NAME: ec1021a8>) (0 . "LAYER") (5 . "10") (330 . <ENTITY NAME: ec102058>) (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "0") (70 . 0) (62 . 7) (6 . "Continuous") (290 . 1) (370 . -3) (390 . <ENTITY NAME: ec102190>) (347 . <ENTITY NAME: ec104350>) (348 . <ENTITY NAME: 0>) (1071 . 33554687))

 

yes, this difference make that situation. 

assoc is simple function, get member of list. 

so, for debug that, have to test inner side like above two command.

in this case, tblsearch's list will response only assoc 0, 2, 70, 62, 6.

and entget  tblobjname will response assoc -1, 0, 5, 330, 100, 2, 70, 62, 6, 290, 370, 390, 347, 348, 1071

 

 

 

 

 

Posted

yes, LW is in 'parent' list, thank you again for your explanation

  • Like 1

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