Passing Values to Entmake ATTDEF

Passing Values to Entmake ATTDEF

mgorecki
Collaborator Collaborator
1,188 Views
5 Replies
Message 1 of 6

Passing Values to Entmake ATTDEF

mgorecki
Collaborator
Collaborator

Hello,

I'm just not sure what's going on with this and I hope a second set of eyes will help.

I have some code that's supposed to create a block that contains an attribute.

This is my code, but it's not working.  I think it fails at "(cons 2 tagName)".

I'm not sure if it's because of the combination of hard code and the variables.  If so, how do you use both methods in the same entmake?

(setq blockName "Test1"
insPt '(0.0 0.0 0.0)
tagName "TAG_NAME"
vis 0
justifyHor 0)
(entmake (list (cons 0 "BLOCK") (cons 2 blockName) (cons 10 '(0.0 0.0 0.0)) (cons 70 2) ) ) (entmake (list '(0 . "ATTDEF") '(1 . "") (cons 2 tagName) '(3 . "Enter Value") '(7 . "RomanS") '(8 . "DIM_1") (cons 10 insPt) (cons 11 insPt) '(40 . 2.20) (cons 71 vis) ;0=visible, 1=invisible (cons 72 justifyHor) ;0=Left, 1=Center, 2=Right '(74 . 2) ;2=Middle ) ) (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) )

Thanks,

Mark

0 Likes
Accepted solutions (1)
1,189 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant

Create an attdef by hand with TAG,PROMPT and VALUE,

check the properties by (entget(car(entsel))) and you will see: gc2 is the TAG, gc3 is the PROMPT, gc1 is the predefined value.

 

Or read the Help about ATTDEF (DXF)

 

 

HTH

Sebastian

0 Likes
Message 3 of 6

dlanorh
Advisor
Advisor

@mgorecki wrote:

Hello,

I'm just not sure what's going on with this and I hope a second set of eyes will help.

I have some code that's supposed to create a block that contains an attribute.

This is my code, but it's not working.  I think it fails at "(cons 2 tagName)".

I'm not sure if it's because of the combination of hard code and the variables.  If so, how do you use both methods in the same entmake?

(setq blockName "Test1"
insPt '(0.0 0.0 0.0)
tagName "TAG_NAME"
vis 0
justifyHor 0)
(entmake (list (cons 0 "BLOCK") (cons 2 blockName) (cons 10 '(0.0 0.0 0.0)) (cons 70 2) ) ) (entmake (list '(0 . "ATTDEF") '(1 . "") (cons 2 tagName) '(3 . "Enter Value") '(7 . "RomanS") '(8 . "DIM_1") (cons 10 insPt) (cons 11 insPt) '(40 . 2.20) (cons 71 vis) ;0=visible, 1=invisible (cons 72 justifyHor) ;0=Left, 1=Center, 2=Right '(74 . 2) ;2=Middle ) ) (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) )

Thanks,

Mark


(cons 0 "BLOCK")

should be

 

(cons 0 "INSERT") or '(0 . "INSERT")

I am not one of the robots you're looking for

0 Likes
Message 4 of 6

cadffm
Consultant
Consultant
Accepted solution

@dlanorh  schrieb:


(cons 0 "BLOCK")

should be

 

(cons 0 "INSERT") or '(0 . "INSERT")

Why? we try to create a block with an attdef, not a insert - it's late, i now 😄

 

 

@mgorecki 

 

1. i totally missunderstood the topic/the issue.

2. i oversaw the dxf code 1 in your code

-- it is late -- sorry

Answer: Acad misses the dxf70

 

 (entmake
  (list
   '(0 . "ATTDEF")
   '(1 . "")
   (cons 2 tagName)
   '(3 . "Enter Value")
   '(7 . "RomanS")
   '(8 . "DIM_1")
   (cons 10 insPt)
   (cons 11 insPt)
   '(40 . 2.20)
   '(70 . 0) ; http://help.autodesk.com/view/ACD/2020/ENU/?guid=GUID-F0EA099B-6F88-4BCC-BEC7-247BA64838A4
   (cons 71 vis) ;0=visible, 1=invisible
   (cons 72 justifyHor) ;0=Left, 1=Center, 2=Right
   '(74 . 2) ;2=Middle
  )



 

Sebastian

0 Likes
Message 5 of 6

mgorecki
Collaborator
Collaborator

Hello CADffm,

I added the '(70 . 0) but unfortunately it still didn't work.  Then the crazy thing; I re-formatted the way I wrote it (based on another program I had written):

(entmake (list (cons 0 "BLOCK")
		(cons 2 blockName)
		(cons 10 '(0.0 0.0 0.0))
		(cons 70 2)
		))
 (entmake (list (cons 0 "ATTDEF")
                (cons 1 "")
                (cons 2 tagName)
                (cons 3 "Enter Value")
                (cons 8 "DIM_1")
                (cons 10 '(0.0 0.0 0.0))
                (cons 11 '(0.0 0.0 0.0))
                (cons 70 0) ;Attribute flags, 1 = Attribute is invisible
                (cons 72 1) ;Horizontal text justification, 1 = Center
                (cons 74 2) ;Vertical text justification, 2 = Middle
                (cons 40 2.20)
		))
 (entmake (list (cons 0 "ENDBLK")
		(cons 8 "0")
		))

That works just fine. I don't know why that would when the other didn't, but hey I'll take it. 🙂

 

Best regards,

Mark

0 Likes
Message 6 of 6

cadffm
Consultant
Consultant

@mgorecki  schrieb:

I added the '(70 . 0) but unfortunately it still didn't work.  Then the crazy thing; I re-formatted the way I

 I don't know why that would when the other didn't, but hey I'll take it. 🙂

 


It works with "I added the '(70 . 0) ", there was another temporary problem in this second of your try.

One hint: You should use the original group code order so long it is easy possible for you - like in this case here!

Because often the order is not important, but often means too: Sometimes the groupcode order is important.

Sebastian

0 Likes