Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
anim8er3
Posts: 20
Registered: ‎08-30-2012
Message 1 of 8 (186 Views)

Why can't I entmake a linetype definition?

186 Views, 7 Replies
09-17-2012 09:56 AM

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

 

*Expert Elite*
dbroad
Posts: 1,480
Registered: ‎08-16-2007
Message 2 of 8 (179 Views)

Re: Why can't I entmake a linetype definition?

09-17-2012 10:19 AM in reply to: anim8er3

Change entmake to entmakex

Contributor
anim8er3
Posts: 20
Registered: ‎08-30-2012
Message 3 of 8 (167 Views)

Re: Why can't I entmake a linetype definition?

09-17-2012 02:50 PM in reply to: dbroad

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.

Contributor
anim8er3
Posts: 20
Registered: ‎08-30-2012
Message 4 of 8 (164 Views)

Re: Why can't I entmake a linetype definition?

09-17-2012 02:53 PM in reply to: anim8er3

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.

*Expert Elite*
dgorsman
Posts: 5,056
Registered: ‎10-12-2006
Message 5 of 8 (161 Views)

Re: Why can't I entmake a linetype definition?

09-17-2012 03:11 PM in reply to: anim8er3

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Valued Contributor
Rtogores
Posts: 84
Registered: ‎02-07-2001
Message 6 of 8 (140 Views)

Re: Why can't I entmake a linetype definition?

09-18-2012 02:39 AM in reply to: dgorsman

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

*Expert Elite*
dbroad
Posts: 1,480
Registered: ‎08-16-2007
Message 7 of 8 (129 Views)

Re: Why can't I entmake a linetype definition?

09-18-2012 06:18 AM in reply to: anim8er3

@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?  

Contributor
anim8er3
Posts: 20
Registered: ‎08-30-2012
Message 8 of 8 (125 Views)

Re: Why can't I entmake a linetype definition?

09-18-2012 06:42 AM in reply to: dbroad

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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community