I tried to use this code to entmake a linetype definition. Why didn't it work?
(if (= (tblobjname "LTYPE" "PHANTOM2") nil)
(entmake (list '(0 . "LTYPE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLinetypeTableRecord") '(2 . "PHANTOM2") '(70 . 0)
'(3 . "Phantom \(.5x\) ___ _ _ ___ _ _ ___ _ _ ___ _ _") '(72 . 65) '(73 . 6) '(40 . 1.25)
'(49 . 0.625) '(49 . -0.125) '(49 . 0.125) '(49 . -0.125) '(49 . 0.125) '(49 . -0.125) '(74 . 0))))
It didn't work. NIL was returned. I don't see any errors in my definition, unless there is a magic order to it I'm unaware of.
This works:
(while (= (tblobjname "LTYPE" "PHANTOM2") nil)
(progn
(setq fname (strcat (getvar "dwgprefix") "PHANTOM2.lin"))
(setq f (open fname "w"))
(princ "*PHANTOM2,Phantom \(.5x\) ___ _ _ ___ _ _ ___ _ _ ___ _ _\nA,.625,-.125,.125,-.125,.125,-.125\n" f)
(close f)
(command "-LINETYPE" "L" "PHANTOM2" fname "")
)
)
But not the method I wanted to use.
I don't have it handy right now, but check in the ENTMAKE help. I seem to remember something about only certain linetypes can be made programmatically, and that some types (symbol/text using?) could not. I could be completely wrong, though.
This function creates a new LINETYPE using entmake:
(defun ent-Linetype (name description param-list) (entmake (append (list '(0 . "LTYPE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLinetypeTableRecord") (cons 2 name) '(70 . 0) (cons 3 description) (cons 72 (ascii (nth 0 param-list))) (cons 73 (- (length param-list) 1)) (cons 40 (apply '+ (mapcar 'abs (cdr param-list))))) (apply 'append (mapcar '(lambda (x) (list (cons 49 x) '(74 . 0))) (cdr param-list))))))
To test is you can use:
(ent-Linetype "LINE_1" "Created by entmake" '("A" 31.75 -6.35 6.35 -6.35))
@anim8er3:
Both your original and the entmakex version should have worked fine and do work fine here.
In general, use entmakex for non-graphical data and entmake for graphical data. The only difference between the two is that entmakex assigns no owner to the new entity.
What version of AutoCAD are you using?
I'm using AutoCAD Map 3D 2011.
This now works:
(if (= (tblobjname "LTYPE" "PHANTOM2")nil)
(entmake (list '(0 . "LTYPE")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLinetypeTableRecord")
'(2 . "PHANTOM2") '(70 . 0) '(3 . "Phantom \(.5x\)___ _ _ ___ _ _ ___ _ _ ___ _ _")
'(72 . 65) '(73 . 6) '(40 . 1.25) '(49 . 0.625) '(74 . 0) '(49 . -0.125) '(74 . 0)
'(49 . 0.125) '(74 . 0) '(49 . -0.125) '(74 . 0) '(49 . 0.125) '(74 . 0) '(49 . -0.125)
'(74 . 0)))
)
Looking at the code for ent-Linetype.lsp (which worked), I noticed that it generates a 74 code for each 49 code. That is apparently necessary for this version of AutoCAD.
Thanks for all the help.