Solved! Go to Solution.
Solved by dgenesse. Go to Solution.
works on 2012 with OTB dynblock at least:
I did have to ensure that the field attribute was visible in all visibility states but everything was pretty straightforward otherwise.
-Gary
Hi Gary,
My program works from inside the block editor.
Insert a visibility parameter. Create an attribute. Set the attribute to the field for the visibility parameter. Note that at this point, the block editor is still running. The block is not being inserted until after the program is completed.
The rest of program really just draws a few objects.
The issue is not making the attribute visible for a particular visibilty, but rather getting the proper field information to link the attribute to the visibility parameter.
Hi All,
Just to clarify, I am working on a subroutine in AutoLISP that works inside the Block editor.
The subroutine basically does the following:
(command "_.bparameter" "v" "l" "VISIBILITY" VIP "1") ; Insert a Visibility parameter at point VIP
;get information to create a field code similar to the manually inserted field - %<\AcObjProp.16.2 Object(?BlockRefId).Parameter(1).VisibilityState \f "%tc1">%
; set VISFIELDTEXT to the field for the visibility
(command "_.attdef" "a" "" "VISATTRIB" "Visibility_Attribute" VISFIELDTEXT "J" "MC" TIP "") ; insert an attirbute called VISATTRIB with the field VISFIELDTEXT at the point TIP
The problem is that the VISFIELDTEXT always gives an improper field. I cannot get the right information to build the field text properly.
well...
First, the utility that generates a field (the little "field" button in the dialog version of attdef) for a replacement value (which is truly what a field is) seems to be beyond reach via Vllisp (and DXF entity definition lists) and ActiveX (vla***) functions/properties (or beyond me in finding a way to reach them short of .NET)
Secondly, The values and codes are stored and accessed via extension dictionaries attached to the attribute via the said "unattainable" function and not within the "string value" of the attribute itself.
I can aquire the field via a couple of methods but ActiveX simply returns it as a generic object instead of the "field" object that is available in .NET.and I have yet to determine how the DXF entity list returned from the field definition ties the result to the object/property that it is reporting on... the returns from the field (which can be accessed via getting the "ACAD_FIELD" dictionary out of the attribute's extension dictionary, and then getting the "AcDbField" from within that (of one that was created by the dialog version).
The DXF codes are represented as: (1 . "_text") (2 . "%<\\_FldIdx 0>%")
whereas the ActiveX return is:
; IAcadObject: The standard interface for a basic AutoCAD object
; Property values:
; Application (RO) = #<VLA-OBJECT IAcadApplication 0171b450>
; Document (RO) = #<VLA-OBJECT IAcadDocument 1330c08c>
; Handle (RO) = "2422"
; HasExtensionDictionary (RO) = 0
; ObjectID (RO) = 2129725968
; ObjectName (RO) = "AcDbField"
; OwnerID (RO) = 2129725960
; Methods supported:
; Delete ()
; GetExtensionDictionary ()
; GetXData (3)
; SetXData (2)
So it seems that there may be some clues in the entity codes to gather data from an existing one but, all in all, I can't find any way to create one.
Sorry, maybe someone more creative than I can get you there, but I can't find a path to do so.
-Gary
So I found the solution and it comes down to sometimes the simplest answer is the one that works.
It turns out that inside the block editor you don't need the object id.
(command "_.bparameter" "v" "l" "VISIBILITY" VIP "1") ; Insert a Visibility parameter at point VIP
(setq VISFIELDTEXT (strcat "%<\\AcObjProp.16.2 Object(?BlockRefId).Parameter(1).VisibilityState \\f \"%tc1\">%")) ; set VISFIELDTEXT to the field for the visibility
(command "_.attdef" "a" "" "VISATTRIB" "Visibility_Attribute" VISFIELDTEXT "J" "MC" TIP "") ; insert an attirbute called VISATTRIB with the field VISFIELDTEXT at the point TIP
Notice that the Object uses Object(?BlockRefId) instead of an object id of a specific entity.