ssg Posted November 10, 2007 Posted November 10, 2007 I usually create new layer by command function. Example: (command "Layer" "N" MyLayer "L" MyLtype MyLayer "C" MyColor MyLayer "T" MyLayer "") I'd like to do it by entmake function. Can anyone help me? Thanks in advance! Quote
VovKa Posted November 10, 2007 Posted November 10, 2007 (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 MyLayer) (cons 6 MyLtype) (cons 62 MyColor) ) ) read DXF reference for more group codes Quote
ssg Posted November 12, 2007 Author Posted November 12, 2007 Thanks a lot! You are professional in lisp! Quote
kpblc Posted November 12, 2007 Posted November 12, 2007 If a layer MyLayer exist in dwg, you'll receive a error. You'd better use smth like this: (defun create-my-layer (name ltype color / res) ;| * Creates a new layer in current dwg. * If layer exist, returns an ename-pointer to it (no changes). If not, layer * has been tried to create with settings. * Call parameters: name Name of layer ltype Name of linetype setted to created layer. If it doesn't exist the linetype "Continuous" will be used color ICA-color for creating layer |; (cond ((tblobjname "layer" "name")) (t (setq res (entmakex (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 name) (cons 6 (cond ((tblobjname "ltype" ltype)) (t "Continuous") ) ;_ end of cond ) ;_ end of cons (cons 62 color) ) ;_ end of list ) ;_ end of entmakex ) ;_ end of setq ) ) ;_ end of cond ) ;_ end of defun Quote
fuccaro Posted November 12, 2007 Posted November 12, 2007 Ssg you need a layer to place something on it, right? Why don't just create the desired object on the layer you need; if the layer exists- it will be used, if it doesn't exists -it will be created. Quote
ssg Posted November 13, 2007 Author Posted November 13, 2007 @kpblc: Thank you! I knew how to using conditional functions: if, cond…. I will add them in specific cases. @fuccaro: Yes, but sometime I need to create new layers without any object (when creating template drawing with customize standards). Thanks everybody! Your ideas are useful for me. But there is a question yet: When I create a normal entity (line, circle, arc…) I don’t need DXF code 100. Example: (entmake (list (cons 0 "LINE") (cons 10 '(100 100)) (cons 11 '(150 200)))) AutoCAD application will automatically add them: AcDbEntity, AcDbLine, AcDbArc, AcDbCircle… to the entity database. But why I must declare DXF code 100 with Layer (and maybe with all objects in Table Group)? Example: (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "MyLayer") (cons 70 0) ) If one of them is missing, new layer will not be created. Who can explain that? Quote
Bilal Posted March 1, 2018 Posted March 1, 2018 (edited) (defun create-my-layer (name ltype color / res) ;| * Creates a new layer in current dwg. * If layer exist, returns an ename-pointer to it (no changes). If not, layer * has been tried to create with settings. * Call parameters: name Name of layer ltype Name of linetype setted to created layer. If it doesn't exist the linetype "Continuous" will be used color ICA-color for creating layer |; (cond ((tblobjname "layer" name)) (t (setq res (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 name) (cons 70 0) (cons 62 color) (cons 6 (cond ((tblobjname "ltype" ltype) ltype) (t "Continuous") ) ;_ end of cond ) ;_ end of cons ) ;_ end of list ) ;_ end of entmake ) ;_ end of setq ) ) ;_ end of cond ) ;_end of defun Edited March 1, 2018 by rkmcswain added [CODE] tags Quote
ronjonp Posted March 1, 2018 Posted March 1, 2018 HERE's another that will let you add a layer description too. ... Oooops .. just realized this thread is over 10 years old Quote
Grrr Posted March 1, 2018 Posted March 1, 2018 *>>* In my head they sounded like "AAaargh.. gimme routines!" Quote
pBe Posted March 1, 2018 Posted March 1, 2018 *>>* Hang on.. I think i recognized the one on the farthest left there... Made you look! Quote
Bilal Posted March 2, 2018 Posted March 2, 2018 :lol::lol: Humurous Guys, I knew, It is too late Quote
dilan Posted November 5, 2018 Posted November 5, 2018 (edited) Hey. Please help me, how can I put the text under the arrow? (defun c:text_! () (while (setq p1 (getpoint (strcat "\nFirst point ->>"))) (setq p2 (getpoint p1 (strcat "\nSecond point ->>"))) (setq *ht* 0.5 di (/ (* *ht* 0.45) 0.5) nm (trans '(0. 0. 1.) 1 0 t) ) (setq a (angle p1 p2)) (entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") '(100 . "AcDbText") '(10 0. 0. 0.) (cons 40 *ht*) (cons 7 (getvar 'textstyle)) (cons 8 "Some layer") (cons 62 1) (cons 1 "Some string") (cons 50 (if (minusp (cos a)) (+ pi a) a ) ) '(72 . 1) (cons 11 (mapcar '(lambda (x1 x2) (/ (+ x1 x2) 2.)) p1 p2)) '(73 . 1) ) ) ; end of entmake (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 3) '(70 . 0) (cons 8 "Some layer") (cons 10 (trans p2 1 nm)) '(40 . 0.0) (cons 41 (/ di 2.0)) (cons 62 21) (cons 10 (trans (polar p2 (angle p2 p1) di) 1 nm)) (cons 10 (trans p1 1 nm)) (cons 210 nm) ) ) ; end of entmake ) (princ) ) Sorry that the question is off topic Edited November 5, 2018 by dilan Quote
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.