Get Face From PickObject(ObjectType.Face)

Get Face From PickObject(ObjectType.Face)

Anonymous
Not applicable
6,001 Views
5 Replies
Message 1 of 6

Get Face From PickObject(ObjectType.Face)

Anonymous
Not applicable

Dear everyone, I pick a face by this:

 

Reference rf = sel.PickObject(ObjectType.Face);

 

How can I retrieve Face f from reference rf? Thank you.

0 Likes
Accepted solutions (1)
6,002 Views
5 Replies
Replies (5)
Message 2 of 6

matthew_taylor
Advisor
Advisor
Accepted solution

Hello @Anonymous,

Searching the SDK yields this example:

Reference faceRef = m_document.Selection.PickObject(ObjectType.Face, _
  new PlanarFaceFilter(m_document.Document), _
  "Please pick a planar face to set the work plane. ESC for cancel.");
GeometryObject geoObject = _
  m_document.Document.GetElement(faceRef).GetGeometryObjectFromReference(faceRef);
PlanarFace planarFace = geoObject as PlanarFace;
 

If you haven't downloaded the SDK, you should now. (see here) Smiley Happy


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 6

jlpgy
Advocate
Advocate

Hi, thanks for you suggestion.

Now I have a further question:

How to obtain a geometry object from a LINKED element.

 

I use PickObject() with ObjectType.PointOnElement to get a Reference object.

If I pick an Element in the host (current/main/master, whatever you call it) document,

<elemInHostDoc>.GetGeometryObjectFromReference(refPickedInHostDoc) 

 The above method works just fine for me.

 

As I had tested: ObjectType.PointOnElement can pick both in host document and in linked document.

If I pick an Element in a linked document, for example, I click a surface of a rectangular Duct, API gave me back a Reference object of which the ElementReferenceType property is SURFACE.

 
 

I had tried calling GetGeometryObjectFromReference in the following 2 ways:

1.

<elemInLinkDoc>.GetGeometryObjectFromReference(pickedRef)
// throw exception : The id of this element is not same as that referenced by reference
Parameter name: reference

2.

<rvtLinkInstanceElement>.GetGeometryObjectFromReference(pickedRef)
// returns <null>

Sooo, How can I obtain a geometry object from a link Element?

Thanks !

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 4 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @jlpgy ,

try using the below link

selecting-a-face-in-a-linked-file 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 5 of 6

Anonymous
Not applicable

As the link:

https://forums.autodesk.com/t5/revit-api-forum/check-out-the-self-paced-guide-my-first-plug-in/m-p/3...

with this statement:

"Note on 5/11/2018: My First Plug-in is being migrated to Knowledge Base (similar to this forum). Right now, the marketing URL is not working. In a mean time, you can access here:
https://knowledge.autodesk.com/community/collection/my-first-autodesk-revit-plug

Still work in progress. Working on updating all the links, to the latest three releases, etc."

 

However as the picture show the link is "Not Found"?!

Could someone give a hand? thx~

404.jpg

0 Likes
Message 6 of 6

matthew_taylor
Advisor
Advisor

Try this one:

https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/simplecontent/content/my-fi... 


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes