Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey Everyone, So dynamo allows you to get an elements geometry and then create a direct shape from the returned geometry. I am trying to do that same thing with API. I want to select a wall get its geometry and then create a direct shape that reflects all the openings in the wall. I originally was going to copy and paste the wall in place then rotate it but revit doesnt alow you to rotate walls in the direction i want.
using (Transaction tx = new Transaction(doc))
{
tx.Start("Generate Tilt Wall");
foreach (ElementId elemId in selectedIds)
{
try
{
Element elem = uidoc.Document.GetElement(elemId);
if((BuiltInCategory)elem.Category.Id.IntegerValue == BuiltInCategory.OST_Walls)
{
Options opts = new Options();
GeometryElement geoEle = elem.get_Geometry(opts);
XYZ newloc = new XYZ(0, 0, 0);
//gets wall curve for rotation
Curve eleCurve = (elem.Location as LocationCurve).Curve;
XYZ startPoint = eleCurve.GetEndPoint(0);
XYZ endPoint = eleCurve.GetEndPoint(1);
//need to set this equal to something so i can modify it
//ICollection<ElementId> newElemColl = ElementTransformUtils.CopyElement(doc, elemId, newloc);
//ElementId newEleId = newElemColl.First();
XYZ pt1 = new XYZ(0, 0, 0);
XYZ pt2 = new XYZ(0, 0, 10);
Line axis = Line.CreateBound(pt1, pt2);
//ElementTransformUtils.RotateElement(doc, newEleId, axis, rotAngle);
DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_Walls));
ds.ApplicationId = "Application id";
ds.ApplicationDataId = "Geometry object id";
ds.SetShape(new GeometryObject[] { geoEle });
}
}
catch(Exception e) { throw e; }
}
tx.Commit();
}
error:
Solved! Go to Solution.