So I'm trying to generate dimensions for a wall segment using the edges of the wall, I can successfully get the wall, get the edges and their references and place them in a reference array, the line I use for my dimension also can be successfully created as a detail line.
So I use the view I got the wall/element from, the line generated from the location line, and some references inside a reference array (will be the edges of the wall but currently as a test the ends of the line as well) but upon trying it doesn't generate a dimension, does not throw an error and also returns the function after running doc.Create.NewDimension without doing the rest of the code.
I've looked at the examples and other similar posts but can't find out what's causing it or how to fix it.
Any help is much appreciated.
public void GenerateDimensionsWall(Document doc, View view)
{
Parameter ref_parameter = view.LookupParameter("LRCZ-Referencing Element");
Wall ele = doc.GetElement(ref_parameter.AsString()) as Wall;
IList<ElementId> e_inserts = ele.FindInserts(true, true, true, true);
foreach (ElementId id in e_inserts)
{
FamilyInstance e = doc.GetElement(id) as FamilyInstance;
LocationPoint locp = e.Location as LocationPoint;
XYZ loc = locp.Point;
IList<Reference> ref_top = e.GetReferences(FamilyInstanceReferenceType.Top);
IList<Reference> ref_bot = e.GetReferences(FamilyInstanceReferenceType.Bottom);
//var a = ref_bot[0].GlobalPoint;
if (ref_top.Count > 0)
{
SpotDimension sd = doc.Create.NewSpotElevation(view, ref_top[0], loc, loc, loc, loc, false);
}
if (ref_bot.Count > 0)
{
SpotDimension sd = doc.Create.NewSpotElevation(view, ref_bot[0], loc, loc, loc, loc, false);
}
}
Options opt = new Options();
opt.ComputeReferences = true;
opt.View = view;
//opt.IncludeNonVisibleObjects = true;
GeometryElement ele_geo = ele.get_Geometry(opt);
foreach (GeometryObject geo_obj in ele_geo)
{
Solid ele_solid = geo_obj as Solid;
FaceArray faces = ele_solid.Faces;
// GET EXTERIOR FACES
PlanarFace face_interior = faces.get_Item(0) as PlanarFace;
PlanarFace face_exterior = faces.get_Item(1) as PlanarFace;
ReferenceArray main_ev_refrences = new ReferenceArray();
ReferenceArray main_eh_refrences = new ReferenceArray();
ReferenceArray sub_ev_refrences = new ReferenceArray();
ReferenceArray sub_eh_refrences = new ReferenceArray();
// GET EXTERIOIR REFRENCES
int e_count = 0;
IList<CurveLoop> e_curveloops = face_exterior.GetEdgesAsCurveLoops();
foreach (CurveLoop cl in e_curveloops)
{
if (e_count == 0)
{
foreach (Curve c in cl)
{
XYZ p1 = c.GetEndPoint(0);
XYZ p2 = c.GetEndPoint(1);
XYZ v = p1 - p2;
if (v.Z < 0)
{
v = p2 - p1;
}
if (v.Z == 0)
{
main_eh_refrences.Append(c.Reference);
}
if (v.Z == 1)
{
main_ev_refrences.Append(c.Reference);
}
}
}
if (e_count > 0)
{
}
e_count++;
}
LocationCurve lc = ele.Location as LocationCurve;
Line line = lc.Curve as Line;
main_ev_refrences.Append(line.GetEndPointReference(0));
main_ev_refrences.Append(line.GetEndPointReference(1));
//Dimension dim1 = doc.Create.NewDimension(view, line, main_ev_refrences);
if (main_ev_refrences.Size > 1)
{
DetailCurve dd = doc.Create.NewDetailCurve(view, line);
// IT RETURNS AFTER TRYING TO MAKE THE DIMENSION WITHOUT AN ERROR OR ANYTHING
Dimension dim2 = doc.Create.NewDimension(view, line, main_ev_refrences);
}
var count = main_ev_refrences.Size;
DetailCurve d2d = doc.Create.NewDetailCurve(view, line);
IList<CurveLoop> i_curveloops = face_interior.GetEdgesAsCurveLoops();
}
}
Solved! Go to Solution.