I know this thread isn't still active, but were you able to get the property set to automatically be inserted with the part? I need to add the custom property, "Weight", to all MEP parts in the catalog and access the property value for each part inserted in a drawing using vba, but I'm stuck.
If your using VBA then there really isnt need to access a property set. You can access the part directly. I do not know VBA but if i was doing it in .net C# i would try to get the value from the object using something like.
internal static bool TryGetValueDouble(Member member, string key, ref double value) { using (var partData = PartManager.GetPartData(member)) { try { DataField field = partData.FindByName(key, false); value = field.ValueDouble; field.Dispose(); return true; } catch { return false; } } }
I don't have the "PartManager" object or "GetPartData" method as an option in vba. Should I give up and just download Visual Studio Express, or do I keep trying with VBA?
The section of code below can work if the value was in a "Property Set" but not "Property Set From Style". Your route of looking at the part would work but what if the cad user had to change the value for the Weight for a single instance of a part? For example, we don't always create a new custom part if we can just throw in an existing one to save time.
Dim SchedApp As New AecScheduleApplication
Dim cPropSets As AecSchedulePropertySets
Dim propSet As AecSchedulePropertySet
Dim cProps As AecScheduleProperties
Dim prop1 As AecScheduleProperty
Dim Weight As Double
If currentobject.Type = "Valve" Then
Set cPropSets = SchedApp.PropertySets(currentobject)
Set propSet = cPropSets.Item("MvPartValveStyles")
Set cProps = propSet.Properties
For Each prop1 In cProps
If prop1.Name = "Weight" Then
Weight = prop1.Value
End If
Next
Hi,
This problem can be solved with the help VBScript with "Formula Definition"
RESULT="--" On Error Resume Next Set app = GetObject (,"AutoCAD.Application") Set sched = app.GetInterfaceObject("AecX.AecScheduleApplication.7.7") vo = [WeightObj] valvPropSet = "MvPartValveStyles" Set vobj = app.ActiveDocument.ObjectIDtoobject ( [ObjectID] ) set style = vobj.Style set propSets = sched.PropertySets(style) For Each propSet In propSets if propSet.Name = valvPropSet Then For Each prop In propSet.Properties If prop.Name = "SupplierName" Then If vo <> "0" Then RESULT = vo Else RESULT = prop.Value End If End If Next End If Next
If the value "WeightObj" = 0 then insert the value from the catalog, else from object
This is what you want?
Vitaly
PS
instead "SupplierName" type value of your catalog