Import family instance to existing floor with specific location in REVIT API(C#)

Import family instance to existing floor with specific location in REVIT API(C#)

Anonymous
Not applicable
2,172 Views
8 Replies
Message 1 of 9

Import family instance to existing floor with specific location in REVIT API(C#)

Anonymous
Not applicable

Hi Guys,

This is somu,  I am new to Revit API developer. Currently, I am looking for import family instance to revit with specified location of the  floor.

Now i am able to create floor and import family instance to the edge point to the new floor.

Please check my code and image below.

 image5.jpgimage6.jpg

 

 

My need is, I have to import the family instance to existing floor with specified location on the floor,  I had tried with some functions and properties, but not able  to place on the floor to specific location. After imported the family, it's has placed as per the xyz values, not on the floor.

I need to extract the existing floor geometrical location and place the family. Need to place the family to specific location on the floor. 

Please check my below code.

 

image4.JPGimage7.jpg

Can anyone suggest/help, where i done mistake or have to update.

 

Thnks

Somu

0 Likes
2,173 Views
8 Replies
Replies (8)
Message 2 of 9

MarryTookMyCoffe
Collaborator
Collaborator

method of newfamilyInstance can be misleading . Try using face of floor :

    public FamilyInstance NewFamilyInstance(Face face, DB.XYZ location, DB.XYZ referenceDirection, DB.FamilySymbol symbol);

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 3 of 9

Anonymous
Not applicable

Hi Marry,

 

Thanks for your reply mail, i have updated my coding with your provided method. I am getting the below error msg:

 

Family cannot be placed as hosted on an input face reference. Because its Familyplacementtype is not workplanebased

Parameter name:symbol.

 

Meanwhile i have updated the familyworkplanebase set to 0.

 

family.get_parameter(Builtinparameter.FAMILY_WORK_PLANE_BASED).SET(0);

 

I am getting the same above mention error.

 

Is there any other options to overcome this issue.

 

Thanks,

Somu

 

 

 

 

0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Dear Somu,

  

MarryTookMyCoffe's suggestion to use the NewFamilyInstance overload taking the floor face sounds good to me.

 

Many thanks to MarryTookMyCoffe for the sound advice!

 

If your family refuses that kind of placement, it may not be usable in the intended manner at all.

 

As always, you need to ensure that your family instance can be placed as required manually in the user interface first, before you start exploring the programming approach.

 

Also, different families have different placement options, and you need to select the right one for your needs:

 

http://thebuildingcoder.typepad.com/blog/2011/01/newfamilyinstance-overloads.html

 

You might want to take a look at other examples of placing family instances, and the research involved in developing them:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.25.2

 

Cheers,

 

Jeremy

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 9

Anonymous
Not applicable

Dear Jeremy  / Marry,

 

Thanks for your provided solutions. Now we are able to place the family instance with some point on the floor. 

Now we are trying the same method to place the doors on wall with some point, we are getting the below error while createfamilyinstance on the wall.

wallerror1.JPG

Please check my coding below, 

 

wallerror2.JPGwallerror3.JPGwallerror4.JPGwallerror5.JPG

 

 

Please suggest me where we done mistake/issue, further solutions.

 

Thanks,

Somu,

 

 

 

0 Likes
Message 6 of 9

jeremytammik
Autodesk
Autodesk

Congratulations on solving your initial problem placing instances on floors!

 

Please share the exact steps that you took to do so, including 

 

  • Changes to the family definition
  • Changes to the NewFamilyInstance overload you used
  • Relevant code snippets
  • Other enhancements you made

 

This will help others facing the same problem.

 

Thank you!

 

Then we can look at the next problem.

 

Maybe it would be cleaner to do so in a new, separate thread?

  

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 9

Anonymous
Not applicable

Dear Jeremy,

 

Please find attached image for updated coding to Import family instance to existing floor with specific location.

 

wallerror6.JPG

 

We had included the inferiorfaceref in the updated code.

 

Thanks for your supporting and giving the solutions, I will create new thread for place door in the existing wall and awaiting for your reply/suggestion.

 

Thanks,

Somu,

 

0 Likes
Message 8 of 9

jeremytammik
Autodesk
Autodesk

Why do you share your code as a picture?

 

Code as text is mostly more useful. For instance, it is found by a search engine.

 

Regardless.

 

You are using the overload taking a face reference, a location, a reference direction and the symbol:

 

  FamilyInstance NewFamilyInstance(
    Reference reference,
    XYZ location,
    XYZ referenceDirection,
    FamilySymbol symbol )

 

The reference direction must be a direction, and is generally normalised.

 

(0,0,0) is not a valid direction and cannot be normalised.

 

I am therefore slightly surprised that this call does not fail, and would assume that it may well fail sometime in the future. 

 

Why don't you specify a valid reference direction if you don't care about it anyway, e.g., XYZ.BasisX?

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 9 of 9

Anonymous
Not applicable

Hi Jeremy,

 

Thanks for your given suggestion, we had updated the reference direction code XYZ.BasisX, its worked fine.

 

Thanks for your supporting,

Somu.

 

 

 

0 Likes