Files
06-Note/Revit-API/ElementTransformUtils.md

75 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

2023-06-20 09:22:53 +08:00
## ElementTransformUtils
### CopyElementargs
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Selection sel = uidoc.Selection;
Reference r = sel.PickObject(ObjectType.Element);
Element element = doc.GetElement(r);
using(Transaction tr = new Transaction(doc))
{
tr.Start("test");
ElementTransformUtils.CopyElement(doc, element.Id, new XYZ(20, 20, 20));
tr.Commit();
}
### CopyElements(args)
### MirrorElement(args)
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Selection sel = uidoc.Selection;
var create = doc.Create;
Reference r = sel.PickObject(ObjectType.Element);
Element element = doc.GetElement(r);
using(Transaction tr = new Transaction(doc))
{
tr.Start("test");
ReferencePlane plane = create.NewReferencePlane(new XYZ(0, 0, 0), new XYZ(0, 0, 20), new XYZ(0, 20, 0), doc.ActiveView);
ElementTransformUtils.MirrorElement(doc, element.Id, plane.Plane);
tr.Commit();
}
### MirrorElements(args
### MoveElement(args)
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Selection sel = uidoc.Selection;
Reference r = sel.PickObject(ObjectType.Element);
Element element = doc.GetElement(r);
using(Transaction tr = new Transaction(doc))
{
tr.Start("test");
ElementTransformUtils.MoveElement(doc, element.Id, new XYZ(20, 20, 20));
tr.Commit();
}
### MoveElements(args)
### RotateElement(args)
-
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Selection sel = uidoc.Selection;
Reference r = sel.PickObject(ObjectType.Element);
Element element = doc.GetElement(r);
using(Transaction tr = new Transaction(doc))
{
tr.Start("test");
Line line = Line.CreateBound(new XYZ(10, 20, 0), new XYZ(10, 20, 30));
// line为旋转的轴要为Z轴方向的线
ElementTransformUtils.RotateElement(doc, element.Id, line,Math.PI/2);
tr.Commit();
}
### RotateElements(args)
*XMind: ZEN - Trial Version*