Reply

Setting Custom Property Value - VB.Net

[ Edited ]

 

Hi

I'm using some of your code examples to retrieve the Value of an Custom Property.

objPropertySets = objPart.GetType().InvokeMember("Properties", BindingFlags.GetProperty, Nothing, objPart, Nothing)

But now I want to round the value and write it back to the Custom Property.

objProperty.Value = Math.Round(GetEWEIGHT1, 3)

But this does not work.

How can I write the value back to the Custom Property using the InvokeMember Method?

 

 

Here the code from my function:

    Public Function GetEWEIGHT1(ByVal objPart As SolidEdgePart.PartDocument) As Double

        Dim objPropertySets As SolidEdgeFramework.PropertySets

        Dim objProperties As SolidEdgeFramework.Properties

 

        objPropertySets = objPart.GetType().InvokeMember("Properties", BindingFlags.GetProperty, Nothing, objPart, Nothing)

 

        objProperties = objPropertySets.Item("Custom")

        For Each objProperty In objProperties

            If objProperty.Name = "EWEIGHT" Then

                GetEWEIGHT1 = CType(Replace(objProperty.Value, ".", ","), Double)

                objProperty.Value = Math.Round(GetEWEIGHT1, 3)

                Exit For

            End If

        Next

        If Not (objProperties Is Nothing) Then

            Marshal.ReleaseComObject(objProperties)

            objProperties = Nothing

        End If

        If Not (objPropertySets Is Nothing) Then

            Marshal.ReleaseComObject(objPropertySets)

            objPropertySets = Nothing

        End If

    End Function

 

Posted by: Florian Tree
Post date: 11/20/2008 11:58:06 PM