Mapping Data from Design Tab to Extended Data Tab (property sets)

Mapping Data from Design Tab to Extended Data Tab (property sets)

Anonymous
Not applicable
2,143 Views
15 Replies
Message 1 of 16

Mapping Data from Design Tab to Extended Data Tab (property sets)

Anonymous
Not applicable

Hi,

 

Is there a way to map data from "Design Tab" to "Extended Data Tab" (property sets) using VBScript?

Can anyone help me please.

 

Thanks,

Christian

2,144 Views
15 Replies
Replies (15)
Message 2 of 16

pendean
Community Legend
Community Legend
May I ask when the intent/final outcome is meant to do when all is said-and-done?
0 Likes
Message 3 of 16

David_W_Koch
Mentor
Mentor

I will echo @pendean's request to explain the purpose of doing this, as it may affect the suggested method.

 

If you just need to have specific data about a particular object show up in a Property (defined in a Property Set Definition), such as the Length of a Wall, you can create an Automatic property using the desired data as the source.  Not all data are available as Automatic properties, however; in those cases it may be possible to use a Formula property to extract the data from the object.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

0 Likes
Message 4 of 16

Anonymous
Not applicable

The object is a block reference. I'm trying to export the file into IFC format. since only properties in extended data (property set) is exported to IFC. I set a user-defined parameter into design tab.I need to map all my parameter from design tab into extended data using a VBscript by using the formula definition. 

0 Likes
Message 5 of 16

Anonymous
Not applicable

 

The VBScript highlighted in red box is not working. any idea hot to map from design tab to extended data.

 

Test101.png

0 Likes
Message 6 of 16

Anonymous
Not applicable

Any Idea???

0 Likes
Message 7 of 16

David_W_Koch
Mentor
Mentor

You are working contrary to the way AutoCAD Architecture is designed.  In AutoCAD Architecture, the expectation is that information will be placed in one or more properties in a property set, and then, if it is desired to show any of that information near the object on which the information was placed, a Schedule Tag would be created and placed to do so.  In that scenario, the data is already on the object, ready to be exported.

 

That said, if you are trying to adapt an existing AutoCAD workflow, in which there are already many drawings with information stored in attributed blocks, it may be possible to do what you want with the right code in the formula property.  (There is no automatic property for reading in an attribute value.)  A quick Google search did not turn up anything posted by someone else who had succeeded in doing this.  I have never needed to try to do this, so I do not have any tried and tested VBScript code to share right now.  Unfortunately, my plate is pretty full right now, but if I do get some free time, I will try to remember to take a stab at this, provided no one else steps in with a solution before then.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

0 Likes
Message 8 of 16

David_W_Koch
Mentor
Mentor

I had a small amount of time this evening, and digging through the ActiveX and VBA Developer's Guide in the Help, determined that the GetAttributes method will return a variant containing a safearray of the attributes attached to a Block Reference object (if there are any).  I vaguely recall running into the problem of how to extract data from a safearray in a VBScript formula, but I do not recall what the solution was (if there was one).  That will have to wait for another day.

 

For what it is worth, I was able to get the list of Attribute References using Visual LISP commands.  So the values are there, I just need to sort out how to access them from VBScript.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

0 Likes
Message 9 of 16

Anonymous
Not applicable

Any update? Or anyone can help? Much appreciated. 

0 Likes
Message 10 of 16

David_W_Koch
Mentor
Mentor

Sorry, I have not had time to get back to this.  Last week was a little busy at work, as one co-worker was at Autodesk University, and the other was doing project work, so I was the Helpdesk for design technology issues last week.

 

Here is what I have so far, in case others care to extend it before I have a chance to revisit this:2017-11-19_FormulaPropertyDefinition_attArrayIsAnArray.png

The last three lines in the formula property definition are just testing what was assigned to various values.  Starting a line with an apostrophe (') makes that line a comment, and it is not executed.  In the image above, you can see that when I test whether attArray is an array, the value is -1, or True.  (A value of 0 would mean False.)  In other tests not shown here, the LBound and UBound functions, which give the lower and upper boundaries of an array, respectively, work on attArray and return values of 0 and 2.  The selected block on which this property is working has three attributes, so that would be consistent with an array of attribute objects for this block.

 

When testing the contents of attRef, which I hoped would contain the first attribute object, it turns out that this variable is uninitialized, so the attRef = attArray(0) line is not working.2017-11-19_FormulaPropertyDefinition_attRefIsEmpty.png

 

 

Given that attRef is Empty, it is not surprising that strTag is also empty.2017-11-19_FormulaPropertyDefinition_strTagIsEmpty.png

 

 

The attached TestAttributeData.lsp file contains five AutoLISP statements that I used to check what sort of data was available from an attributed block.  Below are the results of running those statements, one at a time, on the Visual LISP Console, so you can see the results of each line.  It also includes a vlax-dump-object on the objB1 block object.  The GetAttributes method returns an array containing the attribute objects attached to the block object, as a safearray.  That is likely the reason why trying to get one of the attribute objects using a "regular" array method attRef = attArray(0) in the formula property failed.  AutoLISP has a function to convert a safearray into a list, which is what I used to verify that the contents of the array were in fact three attribute references.  Dumping the properties of one of the attribute references reveals that the TextString property contains the attribute value assigned in the drawing.

_$ (setq b1 (ssget))
<Selection set: 10>
_$ (setq objB1 (vlax-ename->vla-object (ssname b1 0)))
#<VLA-OBJECT IAcadBlockReference 000001f09eedca08>
_$ (vlax-dump-object objB1)
; IAcadBlockReference: AutoCAD Block Reference Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff6b10470d8>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000001f0f9777b88>
;   EffectiveName (RO) = "TestBlock01"
;   EntityTransparency = "ByLayer"
;   Handle (RO) = "3671"
;   HasAttributes (RO) = -1
;   HasExtensionDictionary (RO) = -1
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000001f09f82afc8>
;   InsertionPoint = (0.0 0.0 0.0)
;   InsUnits (RO) = "Inches"
;   InsUnitsFactor (RO) = 1.0
;   IsDynamicBlock (RO) = 0
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Name = "TestBlock01"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 42
;   ObjectName (RO) = "AcDbBlockReference"
;   OwnerID (RO) = 43
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000001f09f82b1a0>
;   Visible = -1
;   XEffectiveScaleFactor = 1.0
;   XScaleFactor = 1.0
;   YEffectiveScaleFactor = 1.0
;   YScaleFactor = 1.0
;   ZEffectiveScaleFactor = 1.0
;   ZScaleFactor = 1.0
T
_$ (setq arr1 (vlax-invoke-method objB1 'GetAttributes))
#<variant 8201 ...>
_$ (setq attList (vlax-safearray->list (vlax-variant-value arr1)))
(#<VLA-OBJECT IAcadAttributeReference 000001f09453f608> #<VLA-OBJECT IAcadAttributeReference 000001f09453f728> #<VLA-OBJECT IAcadAttributeReference 000001f09453fcc8>)
_$ (vlax-dump-object (nth 0 attList))
; IAcadAttributeReference: AutoCAD Attribute Reference Interface
; Property values:
;   Alignment = 10
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff6b10470d8>
;   Backward = 0
;   Constant (RO) = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000001f0f9777b88>
;   EntityTransparency = "ByLayer"
;   FieldLength = 0
;   Handle (RO) = "3673"
;   HasExtensionDictionary (RO) = 0
;   Height = 1.0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000001f0b17d8e58>
;   InsertionPoint = (-1.4352 -0.5 0.0)
;   Invisible = 0
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   LockPosition (RO) = -1
;   Material = "ByLayer"
;   MTextAttribute = 0
;   MTextAttributeContent = ""
;   MTextBoundaryWidth = 0.0
;   MTextDrawingDirection = 5
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 44
;   ObjectName (RO) = "AcDbAttribute"
;   ObliqueAngle = 0.0
;   OwnerID (RO) = 42
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   ScaleFactor = 1.0
;   StyleName = "Arial Non-Annotative"
;   TagString = "TAG01"
;   TextAlignmentPoint = (0.0 0.0 0.0)
;   TextGenerationFlag = 0
;   TextString = "ABC"
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000001f0b17d91b0>
;   UpsideDown = 0
;   Visible = -1
T
_$ 

So, the challenge remains figuring out a way, if it is possible, to extract the value of a safearray in VBScript.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

0 Likes
Message 11 of 16

Anonymous
Not applicable

Hi,

 

Is there any update with this issue?

 

Regards,

0 Likes
Message 12 of 16

David_W_Koch
Mentor
Mentor

Sorry, but I have not had time to get back to this.  Thanks for the reminder.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

0 Likes
Message 13 of 16

Anonymous
Not applicable

Can anyone help me?!

 

 

how about data mapping from excel file into property sets. is that possible?

Message 14 of 16

jtm2020hyo
Collaborator
Collaborator

+1

Did you find any solution?

0 Likes
Message 15 of 16

faugustom
Advocate
Advocate

Try this:

 

Set acadApp = GetObject (,"AutoCAD.Application")
On Error Resume Next
RESULT = "--"

Set aecBase = acadApp.GetInterfaceObject("AecX.AecBaseApplication.8.6")

	aecBase.Init acadApp

Set entObj = acadApp.ActiveDocument.ObjectIDToObject( [ObjectID] )
Set utilObj = aecBase.ActiveDocument.Utility

	AttObj = utilObj.ConvertToVariantArray(entObj.GetAttributes)

RESULT = "TAG: " & AttObj(0).TagString & "/ VALUE: " & AttObj(0).TextString

 

 

0 Likes
Message 16 of 16

faugustom
Advocate
Advocate

Hi David!

 

Using the ConvertToVariantArray is possible to access the attributes array, an using the methods(?) .TextString and .TagString with the array index.
0 Likes