
CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.
Please abide by the
rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
Author |
Topic Search Topic Options
|
CarlB
Senior Member
Joined: 16.Oct.2009
Location: United States
Status: Offline
Points: 321
|
Posted: 23.Feb.2011 at 19:50 |
Revised to take on layer color & linetype. no checking for locked status, etc. Enjoy!
(defun C:NEWL ();R-1, R-2 to reproduce layer settings 2/23/11 (setq PickItem (car (entsel "\nPick object for new layer: ")));R-1 (setq Entdata (entget pickItem)) (setq ObjLayer (cdr (assoc 8 EntData)));R-1 (setq ObjType (cdr (assoc 0 EntData)));R-1 (princ (strcat ObjLayer " is layer name of " ObjType " selected"));R-1 (setq Lyrdata (tblsearch "LAYER" ObjLayer));R-2 (setq LyrLtype (cdr (assoc 6 Lyrdata)));R-2 (setq LyrColor (cdr (assoc 62 Lyrdata)));R-2 (initget "N D V");R-1 (Setq LyrSuffix (getkword "\nEnter suffix type [N-PKG-1/D-PKG1/V-PKG-1]:"));R-1 (setq NewLyrName (cond ((= LyrSuffix "N") (strcat ObjLayer "-N-PKG-1" )) ((= LyrSuffix "D") (strcat ObjLayer "-D-PKG-1")) ((= LyrSuffix "V") (strcat ObjLayer "-V-PKG-1")) ) ) (command "._Layer" "_M" NewLyrname "_C" LyrColor "" "_L" LyrLtype "" "");R-2 (princ) ) |
|
 |
kameron1967
Groupie
Joined: 30.Jan.2011
Location: United States
Using: autocad 2018
Status: Offline
Points: 29
|
Posted: 28.Feb.2011 at 19:06 |
CarlB,
Sorry to keep bothering you. But if I wanted to also include lineweight, but have the ability to modify each aspect of the layer color, linetype and lineweight within the selected suffix - for instance D, can I specify the layer information within the parenthesis? See below. Thanks.
((= LyrSuffix "A")
(setq LyrLtype "sphantom") (setq LyrColor "1") ;(setq LyrLw "0.25") - what's the variable for lineweight?
(strcat ObjLayer "-A-D1C1270" ))
Edited by kameron1967 - 28.Feb.2011 at 20:13
|
 |
CarlB
Senior Member
Joined: 16.Oct.2009
Location: United States
Status: Offline
Points: 321
|
Posted: 28.Feb.2011 at 20:02 |
Well the 'cond' was a subfunction of a 'setq layer' so you should rearrange like below to add more 'setqs' to the cond:
(cond
((= LyrSuffix "A")
(setq xxxlayer (strcat ObjLayer "-A-D1C1270" ))
(setq lyrcolor "1")
(setq lyrltype "continuous") (setq lyrweight "0.25") );R-3
-or shorter versio-
(cond
((= LyrSuffix "A")
(setq xxxlayer (strcat ObjLayer "-A-D1C1270" )
lyrcolor "1"
lyrltype "continuous" lyrweight "0.25" );R-3
|
 |
kameron1967
Groupie
Joined: 30.Jan.2011
Location: United States
Using: autocad 2018
Status: Offline
Points: 29
|
Posted: 28.Feb.2011 at 20:34 |
Thanks, CarlB. I was trying so hard to find the LYRweight variable. I tried LYRLW, LYRLWEIGHT, but couldn't get it to work. I kind of makes sense for the variable to be called LYRweight, but I would never have guessed it. Once again, you're my savior!
One last question: What is the lyrweight number? I never know where to find this info (see below). Thanks.
(setq Lyrdata (tblsearch "LAYER" ObjLayer));R-2 (setq LyrLtype (cdr (assoc 6 Lyrdata)));R-2 (setq LyrColor (cdr (assoc 62 Lyrdata)));R-2
(setq Lyrweight (cdr (assoc ?? Lyrdata)));R-2
Edited by kameron1967 - 28.Feb.2011 at 21:02
|
 |
CarlB
Senior Member
Joined: 16.Oct.2009
Location: United States
Status: Offline
Points: 321
|
Posted: 28.Feb.2011 at 21:03 |
I think we have more to work out...
I had thought you were just assigning a lineweight to a layer with this code, so the variable name could be whatever you want to call it, then that same variable name would be used later in the command to define the new layer:
(command ".-layer" etc.... "_LW" lyrweight etc...)
It you want to assign the same layer weight as object layer selected, will need some other steps...
|
 |
kameron1967
Groupie
Joined: 30.Jan.2011
Location: United States
Using: autocad 2018
Status: Offline
Points: 29
|
Posted: 28.Feb.2011 at 21:07 |
CarlB - there are some layers that require different lineweight to be defined, where the rest uses whatever was assigned in the original layer. I thought if I just set the variable for the lineweight on the layer table, it will default to that, unless I specified it as shown below:
(setq Lyrdata (tblsearch "LAYER" ObjLayer));R-2 (setq LyrLtype (cdr (assoc 6 Lyrdata)));R-2 (setq LyrColor (cdr (assoc 62 Lyrdata)));R-2 (setq Lyrweight (cdr (assoc 370 Lyrdata)));R-2 (LINEWEIGHT)
((= LyrSuffix "X") (setq LyrLtype "sphantom") (setq LyrColor "8") (setq Lyrweight "0.13") (strcat ObjLayer "-X-D1C1270" ));R-3
);R-2
);R-1
(command "-Layer" "_M" NewLyrname "_C" LyrColor "" "_L" LyrLtype "_lw" Lyrweight "" "");R-2 ADDED LINEWEIGHT HERE AS WELL
Edited by kameron1967 - 01.Mar.2011 at 00:23
|
 |
CarlB
Senior Member
Joined: 16.Oct.2009
Location: United States
Status: Offline
Points: 321
|
Posted: 01.Mar.2011 at 07:44 |
Your idea is sound, extracting default data, overriding it later if desired. Since i don't have AutoCADd to check, not sure the 370 code & tblsearch will give you lineweight, or if so will be the correct format to feed back to the "layer" command. You can give me an update on that :)
(defun C:NEWL ();R-1, R-2 to reproduce layer settings 2/23/11 (setq PickItem (car (entsel "\nPick object for new layer: ")));R-1 (setq Entdata (entget pickItem)) (setq ObjLayer (cdr (assoc 8 EntData)));R-1 (setq ObjType (cdr (assoc 0 EntData)));R-1 (princ (strcat ObjLayer " is layer name of " ObjType " selected"));R-1 (setq Lyrdata (tblsearch "LAYER" ObjLayer));R-2 (setq LyrLtype (cdr (assoc 6 Lyrdata)));R-2 (setq LyrColor (cdr (assoc 62 Lyrdata)));R-2 (setq LyrWeight (cdr (assoc 370 Lyrdata)));;R-3 (initget "N D V X");R-1 (setq LyrSuffix (getkword "\nEnter suffix type [N-PKG-1/D-PKG1/V-PKG-1/X-PKG-1]:"));R-1 (cond ((= LyrSuffix "N") (setq NewLyrName (strcat ObjLayer "-N-PKG-1")) ) ((= LyrSuffix "D") (setq NewLyrName (strcat ObjLayer "-D-PKG-1")) ) ((= LyrSuffix "V") (setq NewLyrName (strcat ObjLayer "-V-PKG-1")) ) ((= LyrSuffix "X");;R-3 (setq NewLyrName (strcat ObjLayer "-X-PKG-1")) (setq LyrLtype "PHANTOM") (setq LyrColor "8") (setq LyrWeight "0.13") ) ) (command "._Layer" "_M" NewLyrname "_C" LyrColor "" "_L" LyrLtype "_LW" LyrWeight "" "");R-2&3 (princ) ) |
Edited by CarlB - 01.Mar.2011 at 07:44
|
 |
kameron1967
Groupie
Joined: 30.Jan.2011
Location: United States
Using: autocad 2018
Status: Offline
Points: 29
|
Posted: 01.Mar.2011 at 22:04 |
CarlB,
This is the solution. In addition to the code shown below, the lineweight needs to be 13 instead of 0.13.
Thanks though for your valuable help. I really appreciate your help in this.
[code]
(setq LyrEdata (entget (tblobjname "Layer" ObjLayer)) LyrWeight (cdr (assoc 370 LyrEdata)) ) ((= LyrSuffix "X") (setq NewLyrName (strcat ObjLayer "-X-PKG-1")) (setq LyrLtype "PHANTOM") (setq LyrColor "8") (setq LyrWeight 53)) )
(command "-Layer" "_M" NewLyrname "_C" LyrColor "" "_L" LyrLtype "" "LW" (if (= LyrWeight -3) "D" (/ LyrWeight 100.0)) "" "") (princ) ) (princ "\n<!> Type {LAX} and choose your layer modifier <!>")
|
 |