Make User Parameters Visible

Make User Parameters Visible

Anonymous
Not applicable
879 Views
3 Replies
Message 1 of 4

Make User Parameters Visible

Anonymous
Not applicable

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...

0 Likes
880 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Does any body know how to make Parametric parameters assigned to a block reference visible in the properties palette with .net?  In the Parameters window I right click on a property and select convert.  Then I can choose yes or no on the show column.  And that works manually, telling me there has to be a simple property, or object to modify.  Please help.

 

jvj

0 Likes
Message 3 of 4

Anonymous
Not applicable

Where did you find information on using AssocNetwork?

0 Likes
Message 4 of 4

Anonymous
Not applicable

My text didn't post, so as a 2nd attempt:

In the Object ARX Help guide.  I assumed that most of the commands were wrapped in vb.net, and I was right.

jvj

0 Likes