Accessing GeometryIntent.Geometry.ModelGeometry.ContainingOccurrence.

Accessing GeometryIntent.Geometry.ModelGeometry.ContainingOccurrence.

Anonymous
Not applicable
800 Views
2 Replies
Message 1 of 3

Accessing GeometryIntent.Geometry.ModelGeometry.ContainingOccurrence.

Anonymous
Not applicable

Hello,

     I'm trying to capture out the containing occurrence property value from a list of geometry intent objects. Below is the beginning of the circus hoops I'm jumping through. Getting the "PropertyDescriptorCollection" only works for the top level property: "Geometry". I'm able to find the "ModelGeometry" property but, am unable to dig any deeper using the "PropertyDescriptorCollection" method. Is there a preferred method to collecting this data? Can I get there from where I'm at, if so, how?

 

Thank you in advance.

 

Function GetGeometryIntent(ByVal _intentList As List(Of GeometryIntent), ByVal _compDisplayName As String) As List(Of GeometryIntent)

                Dim _result As New List(Of GeometryIntent)

                Dim _geometryProps As PropertyDescriptorCollection
                ' Dim _modelGeometryProps As PropertyDescriptorCollection
                ' Dim _containingOccurrenceProps As PropertyDescriptorCollection
                Dim _prop1, _prop2, _prop3 As PropertyDescriptor

                For I As Integer = 0 To _intentList.Count - 1
                    _geometryProps = TypeDescriptor.GetProperties(_intentList(I).Geometry)
                    For Each _prop1 In _geometryProps
                        If _prop1.Name.ToUpper = "MODELGEOMETRY" Then
' ????????????????????????????????????????????? ' Here is where I need help.
End If
Next _prop1
Next I
Return _result
End Function

 

0 Likes
801 Views
2 Replies
Replies (2)
Message 2 of 3

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

GeometryIntent.Geometry returns the curve which the GeometryIntent is created from. While DrawingCurve.ModelGeometry returns the corresponding geometry from the model.

 

So I think you may need to get GeometryIntent.Geometry firstly, and get ModelGeometry from GeometryIntent.Geometry

0 Likes
Message 3 of 3

Anonymous
Not applicable

Yeah, I should have informed you that the function is receiving a populated list of GeometryIntent objects already collected from all the drawing view curves. For example, I've already collected all the geometry intent from each circular curve prior to calling this function. I eventually figured it out. The following routine is a good starting point to get data about curves not exposed through the API. And because all the properties are not exposed, you have to provide the full path to the property you are wanting, without intellisense. I used it to automate dimensions on holes. My only question at this point would be; is there a preferred method by Autodesk to access these properties?

            ''' <summary>
            ''' Returns a list of geometry intent objects from a specific component in an assembly drawing.
            ''' </summary>
            ''' <param name="_intentList">Geometry Intent Objects</param>
            ''' <param name="_compParentAssy">Assembly Display name that contains the component.</param>
            ''' <param name="_compDisplayName">Component you are looking for.</param>
            ''' <returns>A list of GeometryIntent from a specific component.</returns>
            ''' <remarks></remarks>
            Private Function GetIntentFromComponent(ByVal _intentList As List(Of GeometryIntent), ByVal _compParentAssy As String, ByVal _compDisplayName As String) As List(Of GeometryIntent)

                Dim _result As New List(Of GeometryIntent)
                Dim _parentOccProps As PropertyDescriptorCollection
                Dim _containingOccProps As PropertyDescriptorCollection
                Dim _prop1, _prop2 As PropertyDescriptor

                For I As Integer = 0 To _intentList.Count - 1
                    _parentOccProps = TypeDescriptor.GetProperties(_intentList(I).Geometry.ModelGeometry.ContainingOccurrence.ParentOccurrence)
                    For Each _prop1 In _parentOccProps
                        If _prop1.PropertyType.GetInterface("IComparable", True) IsNot Nothing Then
                            If _prop1.Name.ToUpper = "NAME" Then
                                Dim value1 As Object = _prop1.GetValue(_intentList(I).Geometry.ModelGeometry.ContainingOccurrence.ParentOccurrence)

                                If value1 = _compParentAssy Then
                                    _containingOccProps = TypeDescriptor.GetProperties(_intentList(I).Geometry.ModelGeometry.ContainingOccurrence)
                                    For Each _prop2 In _containingOccProps
                                        If (_prop2.PropertyType.GetInterface("IComparable", True) IsNot Nothing) Then
                                            If _prop2.Name.ToUpper = "NAME" Then
                                                Dim value As Object = _prop2.GetValue(_intentList(I).Geometry.ModelGeometry.ContainingOccurrence)

                                                If value = _compDisplayName Then
                                                    _result.Add(_intentList(I))
                                                End If
                                                Exit For
                                            End If
                                        End If
                                    Next _prop2
                                End If
                            End If
                        End If
                    Next _prop1
                Next I
                Return _result
            End Function

 

0 Likes