I recently wrote a small tidbit to export all parametric userparameters in a document.
What I need to do is modify it to include Dimensional Contraint information as well.
Any help?
--- My code to export userparameters follows ---
PublicSharedSub CopyParameters()
Dim varId AsObjectId = ObjectId.Null
Dim doc AsDocument = Application.DocumentManager.MdiActiveDocument
Dim db AsDatabase = doc.Database
Dim sClip AsString = ""
Using myT AsTransaction = db.TransactionManager.StartTransaction()
' Open the AssocNetwork
Dim networkId AsObjectId = AssocNetwork.GetInstanceFromObject (SymbolUtilityServices.GetBlockModelSpaceId(db), True, True, "")
Dim network AsAssocNetwork = DirectCast(myT.GetObject(networkId, OpenMode.ForWrite), AssocNetwork)
' Iterate through all actions in the network
Dim actionIds AsObjectIdCollection = network.GetActions
ForEach actionId AsObjectIdIn network.GetActions
If actionId.ObjectClass.IsDerivedFrom(RXObject.GetClass(GetType(Autodesk.AutoCAD.DatabaseServices.AssocVariable))) Then
' Is this action an AssocVariable?
Dim var AsAssocVariable = DirectCast(myT.GetObject(actionId, OpenMode.ForRead), AssocVariable)
If var IsNotNothingThen
sClip = var.Name & ControlChars.Tab & var.Expression.ToString & ControlChars.Tab & var.Value.ToString & ControlChars.NewLine
EndIf
EndIf
Next
EndUsing
If sClip <> ""Then
Clipboard.SetText(sClip)
MessageBox.Show("All FX UserParameters are now on the Windows Clipboard")
Else
MessageBox.Show("No FX UserParameters Found")
EndIf
EndSub
Can't believe I missed my error.
sClip = Var.Name & ControlChars.Tab ...
Should have been
sClip &= Var.Name & ControlChars.Tab ...
As I was not concantinating on each loop only the last entry was saved.
Got a another couple of related questions thougjh.
1) What is the method to retreive parameters by group.
2) The value property does not return what I expected.
Looks like #2 boils down to converting the Value property from a resultbuffer into a typedvalue array. then getting the value property of the typedvalue.
PrivateSharedFunction ResultBufferToText(ByVal rb AsResultBuffer) AsString
Dim tv() AsTypedValue = rb.AsArray
Return tv(0).Value.ToString()
EndFunction
Strange that the documentation does not go into detail about:
Autodesk.AutoCAD.DatabaseServices.TypedValue()
and how to retreive data from them.
It appears that running the objectArx help didn't install help into VB.NET that I can see.