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: 

Place family instance, change orientation.

3 REPLIES 3
Reply
Message 1 of 4
RickyBell
1290 Views, 3 Replies

Place family instance, change orientation.

I'm working on a piping system and I initially wanted to change the symbol of a flange fitting to the symbol of a multiport fitting using this code:

 

FamilySymbol symbol = doc.GetElement(symbolId) as FamilySymbol;

FamilyInstance myMP = myMultiPort as FamilyInstance;
myMP.Symbol = symbol;

 

That doesn't work, I think, because the fittings are of different types.  So, now I'm trying to place my new family instance of the multiport fitting in the same exact spot with the same exact orientation.  Placing it on the correct XYZ was easy, but trying to duplicate it's orientation is proving to be difficult.  HandOrientation is read-only, as is Facing and WorkPlane.

 

I've attempted to rotate with X, Y, and Z, but trigonometry was never my subject.

 

Thanks for any help!

3 REPLIES 3
Message 2 of 4
ollikat
in reply to: RickyBell

Hi

I may not have an ready made answer for you but here's a few things about your issues.

First of all I assume that the flange and the multiport are different families? If that's the case then you can't mix the family symbols of those in the way you showed us. The closest one to what you have tried is the ChangeTypeId() method which allows you to change the used family symbol of the particular instance. But both (existing and target) family symbols (types) must be under the same family.

So as far as I know, you are on the correct path. Rotating the element to wanted orientation, similarly than the previous element can be sometimes tricky task. You just need to figure it out how to do that. If both elements contain connectors that should be pointin in the same direction, that's a information that you could use also. And yes...you can't use facing orientation etc to rotate the element, you need to use ElementTransformUtils::RotateElement() method.

Hope this has any help for you.

Message 3 of 4
RickyBell
in reply to: ollikat

Thanks for the reply.  The flange family and the multiport family are identical but for changing the type.  If I try the ChangeTypeId(), will that affect other placements of the same family or is it per instance?  I'm thinking if I can change the Type to a multiport temporarily, I can then change the symbol to the correct family from there keeping the orientation.

 

I have it pretty close using the ElementRotate(), but complicated angles still aren't perfect.

 

Thanks for your help.

Message 4 of 4
ollikat
in reply to: RickyBell

Hi

ChangeTypeId() is used per instance element. It will change the used type of the particular instance.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community