hi
i need to get dimensions from sketch
here is the code
Element e1 = (Element)Fmly;
ElementId eid = e1.Id;
Transaction t = new Transaction(doc, "fake");
t.Start();
ICollection<ElementId> ids = doc.Delete(eid);
t.RollBack();
foreach (ElementId id in ids)
{
Element ele = doc.GetElement(id);
string name = ele.Name;
list1.Add(name);
if (ele is Sketch)
{
Sketch s = (Sketch)ele;
string name4 = ele.Name;
SketchPlane sp = (SketchPlane)doc.GetElement(name4);
CurveArrArray caa = s.Profile;
foreach (CurveArray ca in caa)
{
foreach (Curve c in ca)
{
}
}
}
else if (ele is Dimension)
{
Dimension d = (Dimension)ele;
string dname = d.Name;
string dvalue = d.Value.ToString();
}
Solved! Go to Solution.
hi
i need to get dimensions from sketch
here is the code
Element e1 = (Element)Fmly;
ElementId eid = e1.Id;
Transaction t = new Transaction(doc, "fake");
t.Start();
ICollection<ElementId> ids = doc.Delete(eid);
t.RollBack();
foreach (ElementId id in ids)
{
Element ele = doc.GetElement(id);
string name = ele.Name;
list1.Add(name);
if (ele is Sketch)
{
Sketch s = (Sketch)ele;
string name4 = ele.Name;
SketchPlane sp = (SketchPlane)doc.GetElement(name4);
CurveArrArray caa = s.Profile;
foreach (CurveArray ca in caa)
{
foreach (Curve c in ca)
{
}
}
}
else if (ele is Dimension)
{
Dimension d = (Dimension)ele;
string dname = d.Name;
string dvalue = d.Value.ToString();
}
Solved! Go to Solution.
Solved by aignatovich. Go to Solution.
Hi! The idea of an element deletion + temporary transaction seems good for me. But source element must have a sketch in such case, e.g. source element should be a Floor, for example.
I think you need to improve your code: first of all, find sketch in ids list, get all model curves references, then find dimensions in this list and filter them - sketch dimensions must have references to sketch model curves (just compare stable representations)
Hi! The idea of an element deletion + temporary transaction seems good for me. But source element must have a sketch in such case, e.g. source element should be a Floor, for example.
I think you need to improve your code: first of all, find sketch in ids list, get all model curves references, then find dimensions in this list and filter them - sketch dimensions must have references to sketch model curves (just compare stable representations)
hi
i am looking to get the sweep/extrusion pathsketch dimensions.
first i am getting the sweep profile and then traversing the curves in the profile..apparently i am getting the wrong dimensions
can you help me out here??
where am i wrong??
Transaction t = new Transaction(doc, "GetElementId's");
t.Start();
ICollection<ElementId> ids = doc.Delete(eid);
t.RollBack();
List<string> sweeplist = new List<string>();
foreach (ElementId id in ids)
{
Element ele = doc.GetElement(id);
string name = ele.Name;
list1.Add(name);
if (ele is Sweep)
{
Sweep s1 = (Sweep)ele;
Sketch s2 = s1.PathSketch;
SketchPlane sp = s2.SketchPlane;
CurveArrArray caa = s2.;
foreach (CurveArray ca in caa)
{
foreach (Curve c in ca)
{
string cleng = c.Length.ToString();
}
}
}
}
hi
i am looking to get the sweep/extrusion pathsketch dimensions.
first i am getting the sweep profile and then traversing the curves in the profile..apparently i am getting the wrong dimensions
can you help me out here??
where am i wrong??
Transaction t = new Transaction(doc, "GetElementId's");
t.Start();
ICollection<ElementId> ids = doc.Delete(eid);
t.RollBack();
List<string> sweeplist = new List<string>();
foreach (ElementId id in ids)
{
Element ele = doc.GetElement(id);
string name = ele.Name;
list1.Add(name);
if (ele is Sweep)
{
Sweep s1 = (Sweep)ele;
Sketch s2 = s1.PathSketch;
SketchPlane sp = s2.SketchPlane;
CurveArrArray caa = s2.;
foreach (CurveArray ca in caa)
{
foreach (Curve c in ca)
{
string cleng = c.Length.ToString();
}
}
}
}
I'm not sure about what you want to achieve.
Perhaps, this will help you:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiapp = commandData.Application; var uidoc = uiapp.ActiveUIDocument; var doc = uidoc.Document; var collector = new FilteredElementCollector(doc); var sweep = (Sweep) collector .OfClass(typeof (Sweep)) .FirstElement(); var profileCurves = sweep .ProfileSketch .Profile .Cast<CurveArray>() .SelectMany(x => x.Cast<Curve>()); TaskDialog.Show("dev", $"Profile curves length: {UnitUtils.ConvertFromInternalUnits(profileCurves.Sum(x => x.Length), DisplayUnitType.DUT_MILLIMETERS)} mm"); return Result.Succeeded; }
I'm not sure about what you want to achieve.
Perhaps, this will help you:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiapp = commandData.Application; var uidoc = uiapp.ActiveUIDocument; var doc = uidoc.Document; var collector = new FilteredElementCollector(doc); var sweep = (Sweep) collector .OfClass(typeof (Sweep)) .FirstElement(); var profileCurves = sweep .ProfileSketch .Profile .Cast<CurveArray>() .SelectMany(x => x.Cast<Curve>()); TaskDialog.Show("dev", $"Profile curves length: {UnitUtils.ConvertFromInternalUnits(profileCurves.Sum(x => x.Length), DisplayUnitType.DUT_MILLIMETERS)} mm"); return Result.Succeeded; }
hi
UnitUtils.ConvertFromInternalUnits(profileCurves.Sum(x => x.Length), DisplayUnitType.DUT_MILLIMETERS)} mm");
thank you @aignatovich for this. i didn't see the units. when i run my code the length is not in mm..
so thanks for helping me out.
hi
UnitUtils.ConvertFromInternalUnits(profileCurves.Sum(x => x.Length), DisplayUnitType.DUT_MILLIMETERS)} mm");
thank you @aignatovich for this. i didn't see the units. when i run my code the length is not in mm..
so thanks for helping me out.
Can't find what you're looking for? Ask the community or share your knowledge.