本文主要是介绍revit二开 项目基点(可见性设置、基点修改及获取),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
项目基点可见性设置
1.revit中显示项目基点
revit中项目基点可以通过:视图–可见性/图形–模型类别–场地找到项目基点,将复选框勾选,点击确定即可显示。
2.revit二开显示项目基点
项目基点存在于模型类别为场地中,所以要想显示项目基点,先得设置场地的可见性,然后再设置项目基点的。
使用View(视图)中的SetCategoryHidden方法进行设置,第一个参数为ElementId,第二设置可见性,false为显示。
目前测试2019、2020、2021revit版本可通过这种方式进行设置
public void displayProjectBasePoint()
{try{using (Transaction tran = new Transaction(m_doc, "DisplayBasePoint")){tran.Start();Categories cates = m_doc.Settings.Categories;//场地Category site = cates.get_Item(BuiltInCategory.OST_Site);m_doc.ActiveView.SetCategoryHidden(site.Id, false);//项目基点Category projectBasePoint = cates.get_Item(BuiltInCategory.OST_ProjectBasePoint);m_doc.ActiveView.SetCategoryHidden(projectBasePoint.Id, false);tran.Commit();}}catch (){}
}
项目基点修改
获取到项目基点的实例,然后遍历找到要修改的实例属性重新赋值。
在revit中安转Lookup插件查看实例属性。
SetValueString()传入的数据单位为mm。
public void modifyProjectBasePoint(string strNorthSouth, string strEastWest, string strElevation, string strAngle)
{try{using (Transaction tran = new Transaction(m_doc, "ModifyProjectBasePoint")){tran.Start();ElementCategoryFilter siteCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_ProjectBasePoint);FilteredElementCollector collector = new FilteredElementCollector(m_doc);IList<Element> siteElements = collector.WherePasses(siteCategoryfilter).ToElements();foreach (var ele in siteElements){//项目基点参数值设置Parameter paramNorthSouth = ele.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM);if (paramNorthSouth != null)paramNorthSouth.SetValueString(strEastWest);Parameter paramEastWest = ele.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM);if (paramEastWest != null)paramEastWest.SetValueString(strNorthSouth);Parameter paramElevation = ele.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM);if (paramElevation != null)paramElevation.SetValueString(strElevation);Parameter paramAngle = ele.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM);if (paramAngle != null)paramAngle.SetValueString(strAngle);}tran.Commit();}}catch{}
}
项目基点获取
与修改项目基点值类似,先获取到项目基点的实例,遍历实例属性获取值,然后通过转换得到基点。
通过.AsDouble()获取到的值为英尺,根据需要自行转换。
public XYZ getProjectBasePoint()
{double dNorthSouth = 0;double dEastWest = 0;double dElevation = 0;double dAngle = 0;ElementCategoryFilter siteCategoryfilter = new ElementCategoryFilter(BuiltInCategory.OST_ProjectBasePoint);FilteredElementCollector collector = new FilteredElementCollector(m_doc);IList<Element> siteElements = collector.WherePasses(siteCategoryfilter).ToElements();foreach (var ele in siteElements){Parameter paramNorthSouth = ele.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM);if (paramNorthSouth != null)dNorthSouth = paramNorthSouth.AsDouble();Parameter paramEastWest = ele.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM);if (paramEastWest != null)dEastWest = paramEastWest.AsDouble();Parameter paramElevation = ele.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM);if (paramElevation != null)dElevation = paramElevation.AsDouble();Parameter paramAngle = ele.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM);if (paramAngle != null)dAngle = paramAngle.AsDouble();}XYZ projectBasePoint = new XYZ(dEastWest, dNorthSouth, dElevation);Transform translationTransform = Transform.CreateTranslation(projectBasePoint);Transform rotationTransform = Transform.CreateRotation(XYZ.BasisZ, dAngle);Transform finalTransform = translationTransform.Multiply(rotationTransform);return finalTransform.Origin;
}
这篇关于revit二开 项目基点(可见性设置、基点修改及获取)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!