Make User Parameters Visible

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Moving right along with my Parametric Block programming tools. I have successfully created several linked parameters with formulas and values, and now I want to be able to show a select few of them in the Properties Palette (NOT Parameters Manager) for the inserted block ref. Taken from Stephen's example, here is my code for creating the AssocVariable (User Parameter)
Public Function AddOrModifyVariable(ByVal varName As String, ByVal varExpression As String, ByVal sourceObjectID As ObjectId, ByVal trans As Transaction) As ObjectId Dim db As Database = sourceObjectID.Database Dim varId As ObjectId = ObjectId.Null Using trans2 As Transaction = trans.TransactionManager.StartTransaction() ' Open the AssocNetwork Dim networkId As ObjectId = AssocNetwork.GetInstanceFromObject(sourceObjectID, True, True, "") Dim network As AssocNetwork = DirectCast(trans2.GetObject(networkId, OpenMode.ForWrite), AssocNetwork) Dim var As AssocVariable = Nothing ' Iterate through all actions in the network Dim actionIds As ObjectIdCollection = network.GetActions For Each actionId As ObjectId In network.GetActions ' Is this action an AssocVariable? If actionId.ObjectClass.IsDerivedFrom(RXObject.GetClass(GetType(Autodesk.AutoCAD.DatabaseServices.AssocVariable))) Then ' If so, we check if it has the name we're looking for. var = DirectCast(trans2.GetObject(actionId, OpenMode.ForWrite), AssocVariable) If var IsNot Nothing Then ' If name matches, then we exit loop and set its expression If var.Name = varName Then Exit For Else var = Nothing End If End If End If Next ' If variable with correct name wasn't found, we create it. If var Is Nothing Then var = New AssocVariable() varId = network.Database.AddDBObject(var) network.AddAction(varId, True) trans2.AddNewlyCreatedDBObject(var, True) var.SetName(varName, True) End If ' Finally we set its expression to the new value. Dim errMsg As String = "" Try var.SetExpression(varExpression, "", True, True, errMsg, False) Dim rb As New ResultBuffer() errMsg = var.EvaluateExpression(rb) var.Value = rb Catch ex As Exception var.SetExpression(varExpression, "", False, False, errMsg, False) End Try trans2.Commit() End Using Return varId End Function
Looking into the idea, I don't know if I need to create a dynamic block property (or if that can be done), or somehow get this AssocVariable to display on its own. Any Ideas?
jvj
PS, I also noticed that the example for creating a parametric Dimension object, does not set the dimension to the right type of Dynamic dimension. (Play with the Constraint From property in the properties palette, be sure to regen in between). Any clue here...