2

I created a custom Mass family, which is a simple cylinder. I'm trying to place it on a specific point on a specific level using the NewFamilyInstance method.

This is the code I'm using to place the instance:

doc.Create.NewFamilyInstance(new XYZ(0, 0, 0), symbol, 
    ele.Document.GetElement(ele.LevelId), 
    Autodesk.Revit.DB.Structure.StructuralType.UnknownFraming);

The problem is that the instance is placed always at level 1, no matter what the input level. I noticed that the input level appears on the instance's Host constraints. Please refer to the image below:

screenshot

Would highly appreciate it if anyone points out my mistake.

Cheers!

Tsahi Asher
  • 1,767
  • 15
  • 28
NIM4
  • 121
  • 1
  • 10

2 Answers2

0

The code seems to be correct for me, check the source of the ele.LevelId.

If you don't find anything to be corrected you can try to change the level after the creation of the family instance:

//Start Transaction
FamilyInstance famInst; //--> your code
famInst.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).Set(/*Level Id*/);
DomCR
  • 533
  • 4
  • 19
0

I used this method to place the Family Instance and it solved the issue:

Create.NewFamilyInstance(interiorFaceRef, location, refDir, symbol)

https://www.revitapidocs.com/2020/be4b822c-829a-7e7b-8c03-a3a324bfb75b.htm

Kcoder
  • 3,422
  • 4
  • 37
  • 56