// https://help.autodesk.com/view/ADSTPR/2019/ENU/?guid=GUID-19A366F0-C51F-45AB-AF0C-46E59ABFD284 // 详见 AdvanceSteel API 介绍 privatevoidCreateHolesInPlate() {// Create a plate and add holes to itPoint3d plateOrig = Point3d.kOrigin;Plane platePlane =newPlane(plateOrig, Vector3d.kZAxis);Plate plate =newPlate(500,500, platePlane, plateOrig);plate.WriteToDb();ConnectionHolePlate connectionHole =newConnectionHolePlate(plate,newMatrix3d());plate.AddFeature(connectionHole);// Create a rectangular arranger for the holes in a 3x2 patternBoundedRectArranger arranger =newBoundedRectArranger(300,200);arranger.Nx =3;arranger.Ny =2;connectionHole.Arranger = arranger;// Define the holes for the setconnectionHole.Hole =newSlottedHole(20.0,52.0, SlottedHole.eDirection.kXAxis); }
在和 Revit API 混合编写的时候,创建 Plate 的代码:
// 暂时没有找到 FabricationTransaction,猜测来自于 Advance Steel 的 API using(FabricationTransaction trans =newFabricationTransaction(_doc,false,"Create structural plate")) {// Create a plate using Advance Steel API (internal Advance Steel units are in mm)Point3d orig =newPoint3d(Utilities.Functions.FEET_TO_MM * plateCenter.X,Utilities.Functions.FEET_TO_MM * plateCenter.Y,Utilities.Functions.FEET_TO_MM * plateCenter.Z);Plate plate =newPlate(newAutodesk.AdvanceSteel.Geometry.Plane(Point3d.kOrigin, Vector3d.kZAxis), orig,2000,1000);plate.Thickness =10;// Write plate to database.plate.WriteToDb();plateUniqueId = plate.GetUniqueId();trans.Commit(); }
_plateId =CreatePlate(XYZ.Zero); // This would generate background calculation (You can see the task running in the Revit "Background processes" window). MovePlate(); bool backgroundCalc = _doc.IsBackgroundCalculationInProgress();// It should be true.
可以通过注册一个 idle 事件在 Revit 空闲的时候去处理需要的逻辑。
// Register for the idling event and wait for the background calculations to finish. uiApp.Idling += IdlingHandler;
// Selecting the elements to create the anchor pattern on Reference eRef &#61; activeDoc.Selection.PickObject(ObjectType.Element,"Pick an element to create the anchor pattern on"); // Start detailed steel modeling transaction using(FabricationTransaction trans &#61;newFabricationTransaction(activeDoc.Document,false,"Create anchor pattern")) {// We create the anchor pattern using Advance Steel classes and objects only.// for more details, please consult http://www.autodesk.com/adv-steel-api-walkthroughs-2019-enuList<FilerObject> filerObjectList&#61;newList<FilerObject>();FilerObject filerObj &#61; Utilities.Functions.GetFilerObject(doc, eRef);if(null&#61;&#61; filerObj){return Result.Failed;}filerObjectList.Add(filerObj);// Point of reference for the anchor pattern. We use GlobalPoint to create the pattern on the plate. GlobalPoint is the point where the plate is being hit when selected.Point3d p1 &#61;newPoint3d(eRef.GlobalPoint.X, eRef.GlobalPoint.Y, eRef.GlobalPoint.Z);Point3d p2 &#61;newPoint3d(p1.x &#43;0.5, p1.y &#43;0.5, p1.z &#43;0.5);AnchorPattern anchorPattern &#61;newAnchorPattern(p1 * Utilities.Functions.FEET_TO_MM, p2 * Utilities.Functions.FEET_TO_MM,newVector3d(1,0,0),newVector3d(0,1,0));anchorPattern.Connect(filerObjectList.ToArray(), Autodesk.AdvanceSteel.ConstructionTypes.AtomicElement.eAssemblyLocation.kOnSite);anchorPattern.WriteToDb();trans.Commit(); }