Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to pick a block in a CADlink

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
joseluisPQG9P
467 Views, 4 Replies

How to pick a block in a CADlink

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.

Labels (4)
4 REPLIES 4
Message 2 of 5

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.

Message 3 of 5

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.

Message 4 of 5

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

 

....

Message 5 of 5

Hello, Andrew

Thanks very much for the insight I didn't use exactly the method you show me because I use python but nearly the same and your answers give enough information to find the solution. Now I'm able to select a CADLink and retrieve the block/GeometryInstance information, thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report