日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Revit二次开发之“创建尺寸标注”

發布時間:2025/3/17 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Revit二次开发之“创建尺寸标注” 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
運行該命令,選中一個可標注的對象,即實現標注。 [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
public?class?TestCommand?:?IExternalCommand
{
????
public?Result?Execute(ExternalCommandData?commandData,?ref?string?message,?Autodesk.Revit.DB.ElementSet?elements)
????{
????????UIDocument?uiDoc?
=?commandData.Application.ActiveUIDocument;
????????Autodesk.Revit.ApplicationServices.Application?app?
=?commandData.Application.Application;
????????Document?doc?
=?uiDoc.Document;
????????Autodesk.Revit.DB.View?view?
=?doc.ActiveView;
????????ViewType?vt?
=?view.ViewType;

????????
if?(vt?==?ViewType.FloorPlan?||?vt?==?ViewType.Elevation)
????????{
????????????Reference?eRef?
=?uiDoc.Selection.PickObject(ObjectType.Element,?"Please?pick?a?curve?based?element?like?wall.");
????????????
if?(eRef?!=?null?&&?eRef.Element?!=?null)
????????????{
????????????????XYZ?dirVec?
=?new?XYZ();
????????????????XYZ?viewNormal?
=?view.ViewDirection;

????????????????LocationCurve?locCurve?
=?eRef.Element.Location?as?LocationCurve;
????????????????
if?(locCurve?==?null?||?locCurve.Curve?==?null)
????????????????{
????????????????????TaskDialog.Show(
"Prompt",?"Selected?element?isn’t?curve?based!");
????????????????????
return?Result.Cancelled;
????????????????}

????????????????
//?location?curve?needs?to?be?perpendicular?to?view?normal
????????????????XYZ?dirCur?=?locCurve.Curve.get_EndPoint(0).Subtract(locCurve.Curve.get_EndPoint(1)).Normalize();
????????????????
double?d?=?dirCur.DotProduct(viewNormal);
????????????????
if?(d?>?-0.000000001?&&?d?<?0.000000001)
????????????????{
????????????????????dirVec?
=?dirCur.CrossProduct(viewNormal);
????????????????????XYZ?p1?
=?locCurve.Curve.get_EndPoint(0);
????????????????????XYZ?p2?
=?locCurve.Curve.get_EndPoint(1);
????????????????????XYZ?dirLine?
=?XYZ.Zero.Add(p1);
????????????????????XYZ?newVec?
=?XYZ.Zero.Add(dirVec);
????????????????????newVec?
=?newVec.Normalize().Multiply(3);
????????????????????dirLine?
=?dirLine.Subtract(p2);

????????????????????p1?
=?p1.Add(newVec);
????????????????????p2?
=?p2.Add(newVec);
????????????????????
//?move?the?dimension?line?a?little?away?the?element’s?curve
????????????????????Line?newLine?=?app.Create.NewLine(p1,?p2,?true);

????????????????????ReferenceArray?arrRefs?
=?new?ReferenceArray();
????????????????????Options?options?
=?app.Create.NewGeometryOptions();
????????????????????options.ComputeReferences?
=?true;
????????????????????options.DetailLevel?
=?DetailLevels.Fine;
????????????????????GeometryElement?element?
=?eRef.Element.get_Geometry(options);
????????????????????GeometryObjectArray?geoObjectArray?
=?element.Objects;
????????????????????
//enum?the?geometry?element
????????????????????for?(int?j?=?0;?j?<?geoObjectArray.Size;?j++)
????????????????????{
????????????????????????GeometryObject?geoObject?
=?geoObjectArray.get_Item(j);
????????????????????????Solid?solid?
=?geoObject?as?Solid;
????????????????????????
if?(solid?==?null)
????????????????????????????
continue;

????????????????????????FaceArrayIterator?fIt?
=?solid.Faces.ForwardIterator();
????????????????????????
while?(fIt.MoveNext())
????????????????????????{
????????????????????????????PlanarFace?p?
=?fIt.Current?as?PlanarFace;
????????????????????????????
if?(p?==?null)
????????????????????????????????
continue;

????????????????????????????p2?
=?p.Normal.CrossProduct(dirLine);
????????????????????????????
if?(p2.IsZeroLength())
????????????????????????????{
????????????????????????????????arrRefs.Append(p.Reference);
????????????????????????????}
????????????????????????????
if?(2?==?arrRefs.Size)
????????????????????????????{
????????????????????????????????
break;
????????????????????????????}
????????????????????????}
????????????????????????
if?(2?==?arrRefs.Size)
????????????????????????{
????????????????????????????
break;
????????????????????????}
????????????????????}
????????????????????
if?(arrRefs.Size?!=?2)
????????????????????{
????????????????????????TaskDialog.Show(
"Prompt",?"Couldn’t?find?enough?reference?for?creating?dimension");
????????????????????????
return?Result.Cancelled;
????????????????????}

????????????????????Transaction?trans?
=?new?Transaction(doc,?"create?dimension");
????????????????????trans.Start();
????????????????????doc.Create.NewDimension(doc.ActiveView,?newLine,?arrRefs);
????????????????????trans.Commit();
????????????????}
????????????????
else
????????????????{
????????????????????TaskDialog.Show(
"Prompt",?"Selected?element?isn’t?curve?based!");
????????????????????
return?Result.Cancelled;
????????????????}
????????????}
????????}
????????
else
????????{
????????????TaskDialog.Show(
"Prompt",?"Only?support?Plan?View?or?Elevation?View");
????????}

????????
return?Result.Succeeded;
????}
}
from:http://revit.5d6d.com/thread-866-1-4.html 與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的Revit二次开发之“创建尺寸标注”的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。