TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ymg on July 31, 2013, 06:17:18 PM

Title: Entmaking Block With Preset Attribute to a Field
Post by: ymg on July 31, 2013, 06:17:18 PM
Trying to entmake a block with an attribute that has as default value
a field.  Value of field should be:

 %<\AcObjProp.16.2 Object(?BlockRefId,1).InsertionPoint \f "%lu2%pt4%pr0">%

Now if I use Cab's MakeEntmake .lsp here is my return:

Code - Auto/Visual Lisp: [Select]
  1. ;; Revision :07/31/2013 @17:37
  2. (defun c:eMake ()
  3.   (entmake '((0 . "BLOCK")
  4.              (100 . "AcDbEntity")
  5.              (67 . 0)
  6.              (8 . "0")
  7.              (100 . "AcDbBlockReference")
  8.              (66 . 1)
  9.              (2 . "elv")
  10.              (10 0.0 0.0 0.0)
  11.              (70 . 2)
  12.             )
  13.   )
  14.   (entmake '((0 . "ATTDEF")
  15.              (100 . "AcDbEntity")
  16.              (67 . 0)
  17.              (8 . "0")
  18.              (100 . "AcDbText")
  19.              (10 -6.400068212824013 -7.5 0.0)
  20.              (40 . 15.0)
  21.              (1 . "####")
  22.              (50 . 0.0)
  23.              (41 . 1.0)
  24.              (51 . 0.0)
  25.              (7 . "Standard")
  26.              (71 . 0)
  27.              (72 . 1)
  28.              (11 0.0 0.0 0.0)
  29.              (100 . "AcDbAttributeDefinition")
  30.              (280 . 0)
  31.              (3 . "Elevation")
  32.              (2 . "Z")
  33.              (70 . 8)
  34.              (73 . 0)
  35.              (74 . 2)
  36.              (280 . 1)
  37.              (71 . 4)
  38.              (72 . 0)
  39.              (11 0.0 0.0 0.0)
  40.              (101 . "Embedded Object")
  41.              (10 0.0 0.0 0.0)
  42.              (40 . 15.0)
  43.              (41 . 0.0)
  44.              (46 . 0.0)
  45.              (71 . 5)
  46.              (72 . 5)
  47.              (1 . "InsertionPoint")
  48.              (7 . "Standard")
  49.              (11 1.0 0.0 0.0)
  50.              (42 . 126.0266030013642)
  51.              (43 . 15.24556616643929)
  52.              (50 . 0.0)
  53.              (73 . 1)
  54.              (44 . 1.0)
  55.              (90 . 3)
  56.              (63 . 256)
  57.              (45 . 1.5)
  58.              (441 . 0)
  59.             )
  60.   )
  61.   (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
  62.   (princ)
  63. ); end eMaker
  64.  

I've tried changing the default value to  (1 . "%<\AcObjProp.16.2 Object(?BlockRefId,1).InsertionPoint \f \"%lu2%pt4%pr0\">%
making sure that I inserted a "\" in front of the embedded quotes.

Did the same at the embedded object definition again no-go

Tried with both at same time still no-go.

Anybody knows how we can do it ?


ymg
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: snownut2 on July 31, 2013, 06:42:39 PM
The best way I've found to know just what DXF codes are required is using the "Browse Drawing Database" option in the Visual Lisp Editor under the "View" menu item.  If you create the attribute manually first then you can inspect the DXF elements, and see just what is required.

Bruce
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: Lee Mac on August 01, 2013, 07:49:01 AM
If you wish to entmake[x] a Field, you will also need to entmake[x] the extension dictionary attached to the annotation object housing the field expression, in addition to the ACAD_FIELD dictionary within this extension dictionary, the TEXT dictionary within the ACAD_FIELD dictionary, and each of the individual FIELD entities contained within the TEXT dictionary - here is a previous attempt (http://bit.ly/13xPNu3) at this route by Tim.

When using the equivalent Visual LISP ActiveX methods to generate the annotation object, the required dictionaries and Field entities are generated automatically for all Field Expressions detected in the content of the annotation object.
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: ymg on August 01, 2013, 08:51:33 PM
Lee,

I don't quite follow you there.

When you say:

Quote
When using the equivalent Visual LISP ActiveX methods to generate the annotation object, the required dictionaries and Field entities are generated automatically for all Field Expressions detected in the content of the annotation object.

I did look at some of your routine for attributes and tried to modify it so I update a block but I get lost in the viual activex stuff.

Maybe my comprehension is wrong when I try to create a field with it or maybe I am using the wrong method.

Thanks for your help!

ymg
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: Lee Mac on August 02, 2013, 07:09:08 AM
I don't quite follow you when you say:
Quote
When using the equivalent Visual LISP ActiveX methods to generate the annotation object, the required dictionaries and Field entities are generated automatically for all Field Expressions detected in the content of the annotation object.

To explain:

When an annotation object (Text, MText, MLeader, Attribute, Dimension) contains a field expression in its content, the object will also contain an extension dictionary containing the ACAD_FIELD dictionary, which itself contains the TEXT dictionary containing one or more FIELD entities as noted above.

By using entmake[x] to create the annotation object, you would need to manually create each of the required FIELD entities, and each of the containing dictionaries before attaching these to the object - this route is demonstrated by Tim's example to which I have provided a link (http://bit.ly/13xPNu3).

When using the equivalent Visual LISP ActiveX methods to generate the annotation object (addtext / addmtext / addmleader etc.), the field expression is automatically detected in the object content and the accompanying field dictionaries are automatically generated by AutoCAD.

As an example, take a look at my Areas to Field (http://bit.ly/1bREB4l) program.

I hope this is a clearer explanation.
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: kruuger on August 02, 2013, 05:16:18 PM
Lee,

I don't quite follow you there.
in short...entmake block with attributes it is a pain. sometimes even not possible. go with vla
kruuger
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: MP on August 02, 2013, 05:20:18 PM
in short...entmake block with attributes it is a pain. sometimes even not possible.

Have to disagree, sometime later I may search out examples I've posted in the past.
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: Lee Mac on August 02, 2013, 05:39:36 PM
in short...entmake fields it is a pain. sometimes even not possible. go with vla

FTFY.
Title: Re: Entmaking Block With Preset Attribute to a Field
Post by: MP on August 02, 2013, 07:42:26 PM
FTFY.

Agree, it's convoluted.