Accessing linked CAD geometry

Accessing linked CAD geometry

Anonymous
Not applicable
778 Views
1 Reply
Message 1 of 2

Accessing linked CAD geometry

Anonymous
Not applicable

I am using a function to access the geometry of linked CAD files. Then function accepts an import instance as an argument and returns a list of geometry objects contained within the linked file. The function works great in Revit 2015 but I get an error in Revit 2014. It appears that the GetInstanceGeometry method does not return anything. I've tried using GetSymbolGeometry but that didn't work either. Any ideas why this works in 2015 but not in 2014? Here's the function:

 

Function GetLinkedDWGCurves(curLink As ImportInstance) As List(Of Geometryobject)
        'returns list of curves for linked DWG file
        Dim curveList As New List(Of GeometryObject)
        Dim curOptions As New Options
        Dim geoElement As GeometryElement
        Dim geoInstance As GeometryInstance
        
        'get geometry from current link
        geoElement = curLink.Geometry(curOptions)
        
        For Each geoObject As GeometryObject In geoElement
            'convert geoObject to geometry instance
            geoInstance = DirectCast(geoObject, GeometryInstance)
            
            'loop through geometry objects in the geometry instance
            For Each curObj As GeometryObject In geoInstance.GetInstanceGeometry()
                'add object to list
                curveList.Add(curObj)
            Next
        Next
        
        'return list of geometry
        Return curveList
    End Function

 

0 Likes
779 Views
1 Reply
Reply (1)
Message 2 of 2

mikako_harada
Community Manager
Community Manager

Hi Gehry, 

 

Are you using the same project file and a model, just a version difference?  Here is some explanation in case it helps to clarify. 

 

"GeometryInstance Class 

A GeometryInstance represents a set of geometry stored by Revit in a default configuration, and then transformed into the proper location as a result of the properties of the element. The most common situation where GeometryInstances are encountered is in Family instances. Revit uses GeometryInstances to allow it to store a single copy of the geometry for a given family and reuse it in multiple instances. Note that not all Family instances will include GeometryInstances. When Revit needs to make a unique copy of the family geometry for a given instance (because of the effect of local joins, intersections, and other factors related to the instance placement) no GeometryInstance will be encountered; instead the Solid geometry will be found at the top level of the hierarchy. A GeometryInstance offers the ability to read its geometry through the GetSymbolGeometry() and () methods. These methods return another Autodesk.Revit.DB.GeometryElement which can be parsed just like the first level return." 
 
If you can attach a minimum project file (with only a problematic object, for example) and 2014 version of a model, together with ready-to-run, minimum sample MSVS project, we can try to take a look. 
 

Mikako Harada
Developer Technical Services
0 Likes