Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

vbscript in property sets

Anonymous

vbscript in property sets

Anonymous
Not applicable
It appears that you can use many parts of vbscript in property sets but how do you get the property set to fire the code and return the result?



Example:
' this function should return the value of 1 to whatever property formula that calls it.

Public Function x()
x = 1
End Function


Scott Arvin with Autodesk knows something about this... He wrote a brain dump that can be found here:
http://discussion.autodesk.com/servlet/JiveServlet/download/52-150795-2668751-26558/BrainDump_PropertyDataEnhancements.pdf
which is referenced here:
http://discussion.autodesk.com/thread.jspa?messageID=554372

One would conclude from page four of Scott's article that the following function if called from another property formula definition would return the correct value of 1.

Public Function RESULT()
RESULT = 1
End Function

But instead it returns the whole text of the function

So how do I really call that function in a property formula definition?

Can you really have a vbscript Sub or Function in a Property Formula Definition and have it return a result?

Here is the impact of this ability...
working with a abs pipe object that has endpoint, startpoint
varible objID would be passed into this vbscript function framework as the property set automatic formula [ObjectID]

Function getpoints01

Dim cadobj01 As Object

Set cadobj01 = ThisDrawing.ObjectIdToObject(objID)

Dim startPoint As Variant
Dim endPoint As Variant

startPoint = cadobj01.startPoint
endPoint = cadobj01.endPoint

getpoints01 = startPoint(2)

End Function

the return value of getpoints01 would be the z value of the start point of the object and you could pass this value to other property formula definitions to get slope and stuff, etc.

Basically this would build the bridge between the extended data property set information back to the "Design" tab information of the properties dialog box.

Or another question to this might be...
How can I call a vb function from vbscript that is executed/fired inside a property set - property formula defintion?
Reply
610 Views
3 Replies
Replies (3)

Anonymous
Not applicable
I do not believe that external functions or variables can be passed to property set def script.

However, if you want to calculate something such as the volume of a pipe you could use:

RESULT=[Length] * 3.141592653589793 * ([PipeSegmentCatalogData:ND1.1]/2)^2

Of course, you would have to create the [Length] and have it defined as an automatic property definition.

You can create other Automatic PSDs, i.e., Location X, Location Y, and Location Z is available (this appears to be the start point... the endpoint doesn't seem to be 'exposed'). It appears that not all the 'Design' tab information is exposed as a candidate for an Automatic Property.. I'd suggest that you add this as a request in the Wish List section... i.e., "Provide automatic properties for all object properties on the 'Design' Tab".

I don't believe that there is any capability to call an external function from within a property def... This could be dangerous... i.e., a poorly formed For Next, or Do While statment could cause infinite looping. Not good.

Hope this helps.
Martin Schmid
BSD Project Consultant
Autodesk Consulting
0 Likes

Anonymous
Not applicable
looping could be protected from with proper error handling and vbscript does allow for "on error resume next".

wish list is definitely where this issue is heading.

thanks for your comments 😉
0 Likes

Anonymous
Not applicable
I was hoping that you had figured this out. If so could you please inform me of your soultion.......here is my problem if you are curious. Thank you for any help you maybe able to provide.
0 Likes