public static CreateDimensionElement ( View view, XYZ p1, System.Reference r1, XYZ p2, System.Reference r2 ) : void | ||
view | View | |
p1 | XYZ | |
r1 | System.Reference | |
p2 | XYZ | |
r2 | System.Reference | |
Résultat | void |
public static void CreateDimensionElement(
View view,
XYZ p1,
Reference r1,
XYZ p2,
Reference r2)
{
Document doc = view.Document;
ReferenceArray ra = new ReferenceArray();
ra.Append( r1 );
ra.Append( r2 );
Line line = Line.CreateBound( p1, p2 );
using( Transaction t = new Transaction( doc ) )
{
t.Start( "Create New Dimension" );
Dimension dim = doc.Create.NewDimension(
view, line, ra );
t.Commit();
}
}
/// <summary> /// External command mainline. Run in the sample /// model Z:\a\rvt\dimension_case_2015.rvt, e.g. /// </summary> public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; JtPairPicker <FamilyInstance> picker = new JtPairPicker <FamilyInstance>(uidoc); Result rc = picker.Pick(); if (Result.Failed == rc) { message = "We need at least two " + "FamilyInstance elements in the model."; } else if (Result.Succeeded == rc) { IList <FamilyInstance> a = picker.Selected; _opt = new Options(); _opt.ComputeReferences = true; _opt.IncludeNonVisibleObjects = true; XYZ[] pts = new XYZ[2]; Reference[] refs = new Reference[2]; pts[0] = (a[0].Location as LocationPoint).Point; pts[1] = (a[1].Location as LocationPoint).Point; refs[0] = GetFamilyInstancePointReference(a[0]); refs[1] = GetFamilyInstancePointReference(a[1]); CmdDimensionWallsIterateFaces .CreateDimensionElement(doc.ActiveView, pts[0], refs[0], pts[1], refs[1]); } return(rc); }