Kirk Posted November 17, 2006 Share Posted November 17, 2006 Hi Guys, I want to create a new drawing layer in an autolisp program and then draw an object using it. How would I do this and how do make sure the layer dosen't already exist? Thanks Kirk Quote Link to comment Share on other sites More sharing options...
fixo Posted November 17, 2006 Share Posted November 17, 2006 Hi Guys, I want to create a new drawing layer in an autolisp program and then draw an object using it. How would I do this and how do make sure the layer dosen't already exist? Thanks Kirk Hi Kirk Try this one ;Linetype load, assuming you need it for new layer (defun ltype_set (ltname) (if (not (tblsearch "LTYPE" ltname)); Check to see if linetype exsists (if (findfile "acad.lin") (command "._Linetype" "_Load" ltname "acad.lin" ""); if linetype does found (setq ltname "Continuous");if not set linetype to Continuous ) ) ) ;Call example: (ltype_set "DASHED") ;Make new layer ans set it current (defun layer_set (lyr col ltname) (if (tblsearch "LAYER" lyr) ; Check to see if layer exsists (command "._Layer" "_Thaw" lyr "_UnLock" lyr "_On" lyr "_Set" lyr ""); if layer exsists,set it current ;;; ** if not make this layer : ** (if (tblsearch "LTYPE" ltname);if linetype exsists (command "._Layer" "_Make" lyr "_Color" col lyr "_LT" ltname lyr "") (command "._Layer" "_Make" lyr "_Color" col lyr "_LT" "Continuous" lyr "") ) ) ) ;Call example: (layer_set "VMI-LINER" "92" "DASHED");=> change color "92" to your standards Hth ~'J'~ Quote Link to comment Share on other sites More sharing options...
CarlB Posted November 17, 2006 Share Posted November 17, 2006 Here's the short version approach. With "make" you don't need to check if new layer exists, it will make it if nit doesn't exist, or "set" it (make current) if it does exist. (command "._layer" "_M" "newlayername" "") Quote Link to comment Share on other sites More sharing options...
Kirk Posted November 17, 2006 Author Share Posted November 17, 2006 THanks Guys, i've got different layers in my program now. I have another question though. I'm using a centerline in the drawing, but it the scale isn't always right for the size of the part. How do you change the linetype scale in the program? Thanks again Kirk:) Quote Link to comment Share on other sites More sharing options...
fixo Posted November 18, 2006 Share Posted November 18, 2006 THanks Guys, i've got different layers in my program now. I have another question though. I'm using a centerline in the drawing, but it the scale isn't always right for the size of the part. How do you change the linetype scale in the program? Thanks again Kirk:) Hi, Kirk I don't know is there will be my poor explanation useful to you From Help Control Linetype Scale You can use the same linetype at different scales by changing the linetype scale factor either globally or individually for each object. By default, both global and individual linetype scales are set to 1.0. The smaller the scale, the more repetitions of the pattern are generated per drawing unit. For example, with a setting of 0.5, two repetitions of the pattern in the linetype definition are displayed for each drawing unit. Short line segments that cannot display one full linetype pattern are displayed as continuous. You can use a smaller linetype scale for lines that are too short to display even one dash sequence. The Linetype Manager displays the Global Scale Factor and Current Object Scale. The Global Scale Factor value controls the LTSCALE system variable, which changes the linetype scale globally for both new and existing objects. The Current Object Scale value controls the CELTSCALE system variable, which sets the linetype scale for new objects. The CELTSCALE value is multiplied by the LTSCALE value to get the displayed linetype scale. You can easily change linetype scales in your drawing either individually or globally. In a layout, you can adjust the scaling of linetypes in different viewports with PSLTSCALE. In addition to written above there a many ways to change linetype scale for the created entity, i.e., immediatelly after some entitity would be created, you can change linetype scale of it with command CHANGE or CHPROP: (setq p1 (getpoint "\nPick first point: ") p2 (getpoint p1 "\nPick first point: ")) (command "line" p1 p2 "") (setq ln (entlast)); -> obtain the name of a new entity that has ;just been added with the command function. ;make sure "Center" linetype does exist in your drawing, ;see my prior post (command "change" ln "" "Properties" "LType" "CENTER" "ltScale" 0.5 "") ;or with short entry: (command "change" ln "" "P" "LT" "CENTER" "S" 0.5 "") ;instead of using ENTLAST you can use L-letter also: (command "change" "L" "" "P" "LT" "CENTER" "S" 0.5 "");L - Last entity ;or with command CHPROP: (command "chprop" "L" "" "P" "LT" "CENTER" "S" 0.5 "");L - Last entity Another way to modify entity list (setq ln (entlast)) (setq elist (entget ln)) if this line was drawn with linetype scale 1.0 and linetype of this entity is "Continuous" in this case groups with dxf code 6 and 48 would not shown in this entity, i.e.: [0] (-1 . ) [1] (0 . "LINE") [2] (330 . ) [3] (5 . "58CFD") [4] (100 . "AcDbEntity") [5] (67 . 0) [6] (410 . "Model") [7] (8 . "DIM") [8] (62 . 1) [9] (100 . "AcDbLine") [10] (10 -97.5171 60.4786 0.0) [11] (11 297.401 60.4786 0.0) [12] (210 0.0 0.0 1.0) You can enter new linetype and modify this entity list: (setq ltp (getstring "\nEnter the new linetype <Center>: ")) (if (eq "" ltp)(setq ltp "Center"));if Enter pressed set to default ;search for dxf group 6: (if (assoc 6 elist); if 6 group is there, then substitute it: (setq elist (subst (cons 6 ltp)(assoc 6 elist) elist)) ;; But if 6 group isn't there you need to append it into list: (setq elist (append elist (list (cons 6 ltp)))) ) Then you can enter new ltype scale and modify this entity list again: (setq scl (getreal "\nEnter the new linetype scale <0.5>: ")) (if (not scl)(setq scl 0.5));if Enter pressed set to default ;search for dxf group 48: (if (assoc 48 elist); if 48 group is there, then substitute it: (setq elist (subst (cons 48 scl)(assoc 48 elist) elist)) ;; But if 48 group isn't there you need to append it into list: (setq elist (append elist (list (cons 48 scl)))) ) After all these manipulations you need to modify entity list: (entmod elist) Then update an entity: (entupd ln); _end You must be to see "Modifying an Entity" in Help also Maybe somebody else will be explain this much better than me Wish you success on this way ~'J'~ Quote Link to comment Share on other sites More sharing options...
Kirk Posted November 18, 2006 Author Share Posted November 18, 2006 Thanks again for your help. Kirk Quote Link to comment Share on other sites More sharing options...
fixo Posted November 18, 2006 Share Posted November 18, 2006 Thanks again for your help. Kirk You are welcome ~'J'~ Quote Link to comment Share on other sites More sharing options...
nmareis Posted January 17, 2014 Share Posted January 17, 2014 in that comand how do i put the color ? (command "._layer" "_M" "newlayername" "") Quote Link to comment Share on other sites More sharing options...
SLW210 Posted January 17, 2014 Share Posted January 17, 2014 You already have an active thread for this issue. Why did you add-on to a 6+ year old thread? Quote Link to comment Share on other sites More sharing options...
nmareis Posted January 17, 2014 Share Posted January 17, 2014 sorry was a question I had .. but I is solved ... thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.