Hi, I want to pick a cad block from a linked Cad and retrieve block name and layer, similar to native query tool. I have tried with Selection.PickObject(ObjectType.PointOnElement) and I was able to retrieve the layer from the reference I picked but I can't access to the GeometryInstance object.
Anyone have an insight on the matter, thanks.
Solved! Go to Solution.
Hi, I want to pick a cad block from a linked Cad and retrieve block name and layer, similar to native query tool. I have tried with Selection.PickObject(ObjectType.PointOnElement) and I was able to retrieve the layer from the reference I picked but I can't access to the GeometryInstance object.
Anyone have an insight on the matter, thanks.
Solved! Go to Solution.
Solved by AndrewButenko. Go to Solution.
Hello!
I used this method.
First, you need to collect in the list all uniqIds from GeometryInstance that are in ImportInstance.
After that run
Dim R As Reference =uidoc.Selection.PickObject(ObjectType.PointOnElement, New SelectDWGFilter(doc))
SelectDWGFilter allows you to select an ImportInstance.
And then compare the UniqID R.ConvertToStableRepresentation(doc) with the UniqID that is in our original list.
After the object is found, independently "draw" the selection of the object.
Hello!
I used this method.
First, you need to collect in the list all uniqIds from GeometryInstance that are in ImportInstance.
After that run
Dim R As Reference =uidoc.Selection.PickObject(ObjectType.PointOnElement, New SelectDWGFilter(doc))
SelectDWGFilter allows you to select an ImportInstance.
And then compare the UniqID R.ConvertToStableRepresentation(doc) with the UniqID that is in our original list.
After the object is found, independently "draw" the selection of the object.
Hello, @AndrewButenko,
I tried your solution but I still don't get it. When I collect all GeometryInstances from a CADLink, the GeometryInstance class doesn't have the UniqueId property I tried with GetInstanceGeometry() and GetSymbolGeometry() methods with no results. The SymbolGeometry property retrieve a set of geometries that compone the GeometryInstance and are the same that the ones that you get when you use
ref = Selection.PickObject(ObjectType.PointOnElement, "Whatever")
el = Document.GetElement(ref.ElementId)
geo = el.GetGeometrytObjectFromReference(ref)
But I don't find a way to compare the objects because some GeometryObjects like polyline don't have the Reference property to use ConvertToStableRepresentation() method. I'm a little confuse actually.
Thanks for the answer and if you have a more detailed example I would appreciate a lot, thanks again.
Hello, @AndrewButenko,
I tried your solution but I still don't get it. When I collect all GeometryInstances from a CADLink, the GeometryInstance class doesn't have the UniqueId property I tried with GetInstanceGeometry() and GetSymbolGeometry() methods with no results. The SymbolGeometry property retrieve a set of geometries that compone the GeometryInstance and are the same that the ones that you get when you use
ref = Selection.PickObject(ObjectType.PointOnElement, "Whatever")
el = Document.GetElement(ref.ElementId)
geo = el.GetGeometrytObjectFromReference(ref)
But I don't find a way to compare the objects because some GeometryObjects like polyline don't have the Reference property to use ConvertToStableRepresentation() method. I'm a little confuse actually.
Thanks for the answer and if you have a more detailed example I would appreciate a lot, thanks again.
Hello!
Try to do it like this:
Dim dwg As ImportInstance = doc.GetElement(dwgId)
For Each geometryObj As GeometryObject In dwg.Geometry(New Options())
If geometryObj.GetType Is GetType(GeometryInstance) Then
Dim dwgInstance As GeometryInstance = geometryObj
For Each blockObject As GeometryObject In dwgInstance.SymbolGeometry
If blockObject.GetType Is GetType(GeometryInstance) Then
Dim blockInstance As GeometryInstance = blockObject
Dim name As String = blockInstance.Symbol.Name
sUniqID = blockInstance.Symbol.UniqueId
....
Hello!
Try to do it like this:
Dim dwg As ImportInstance = doc.GetElement(dwgId)
For Each geometryObj As GeometryObject In dwg.Geometry(New Options())
If geometryObj.GetType Is GetType(GeometryInstance) Then
Dim dwgInstance As GeometryInstance = geometryObj
For Each blockObject As GeometryObject In dwgInstance.SymbolGeometry
If blockObject.GetType Is GetType(GeometryInstance) Then
Dim blockInstance As GeometryInstance = blockObject
Dim name As String = blockInstance.Symbol.Name
sUniqID = blockInstance.Symbol.UniqueId
....
Can't find what you're looking for? Ask the community or share your knowledge.