简体   繁体   English

使用 Revit API 在模型中放置自定义体量族实例

[英]Placing a custom mass family instance in a model using Revit API

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.我正在尝试使用 NewFamilyInstance 方法将其放置在特定级别的特定点上。

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.问题在于,无论输入级别如何,实例始终放置在级别 1。 I noticed that the input level appears on the instance's Host constraints.我注意到输入级别出现在实例的主机约束上。 Please refer to the image below:请参考下图:

截屏

Would highly appreciate it if anyone points out my mistake.如果有人指出我的错误,我将不胜感激。

Cheers!干杯!

The code seems to be correct for me, check the source of the ele.LevelId. 该代码对我来说似乎是正确的,请检查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*/);

I used this method to place the Family Instance and it solved the issue:我用这个方法来放置Family Instance,它解决了这个问题:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM