Get Solid Geometry From Rebar.

Get Solid Geometry From Rebar.

DesignGroup01
Enthusiast Enthusiast
1,200 Views
5 Replies
Message 1 of 6

Get Solid Geometry From Rebar.

DesignGroup01
Enthusiast
Enthusiast

Hi All,

 

i want to get rebar geometry as solid. as below code i get the rebar diameter & rebar centerlines. then i want use below method.

public static Solid CreateSweptGeometry(
	CurveLoop sweepPath,
	int pathAttachmentCrvIdx,
	double pathAttachmentParam,
	IList<CurveLoop> profileLoops,
	SolidOptions solidOptions
)

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
    try
    {
        UIApplication uiApp = commandData.Application;
        UIDocument uiDoc = uiApp.ActiveUIDocument;
        Document doc = uiDoc.Document;

        // Step 1: Retrieve assemblies in the project and select one
        List<AssemblyInstance> assemblies = new FilteredElementCollector(doc)
            .OfClass(typeof(AssemblyInstance))
            .Cast<AssemblyInstance>()
            .ToList();

        AssemblySelector assemblySelector = new AssemblySelector(assemblies);
        bool? dialogResult = assemblySelector.ShowDialog();

        if (dialogResult != true || assemblySelector.SelectedAssembly == null)
        {
            return Result.Cancelled;
        }

        AssemblyInstance selectedAssembly = assemblySelector.SelectedAssembly;

        // Step 2: Retrieve all structural rebars in the selected assembly
        ICollection<ElementId> memberIds = selectedAssembly.GetMemberIds();
        List<Rebar> rebars = new List<Rebar>();

        foreach (ElementId memberId in memberIds)
        {
            Element member = doc.GetElement(memberId);
            if (member is Rebar rebar)
            {
                rebars.Add(rebar);
            }
        }

        if (rebars.Count == 0)
        {
            TaskDialog.Show("Rebar Clash", "No rebars found in the selected assembly.");
            return Result.Cancelled;
        }

        // Step 3: Collect rebar diameter and centerline curves
        StringBuilder messageBuilder = new StringBuilder();

        foreach (Rebar rebar in rebars)
        {
            // Get the rebar's bar diameter (radius = diameter / 2)
            double diameter = rebar.get_Parameter(BuiltInParameter.REBAR_BAR_DIAMETER).AsDouble();
            double radius = diameter / 2;

            // Get the rebar's centerline curves
            IList<Curve> centerlineCurves = rebar.GetCenterlineCurves(
                adjustForSelfIntersection: true,
                suppressHooks: false,
                suppressBendRadius: false,
                MultiplanarOption.IncludeAllMultiplanarCurves,
                0);

            // Build the message for this rebar
            messageBuilder.AppendLine($"Rebar Id: {rebar.Id.IntegerValue}");
            messageBuilder.AppendLine($"Diameter: {diameter} (feet)");
            messageBuilder.AppendLine("Centerline Curves:");

            foreach (Curve curve in centerlineCurves)
            {
                messageBuilder.AppendLine($"- Curve: Start: {curve.GetEndPoint(0)}, End: {curve.GetEndPoint(1)}");
            }

            messageBuilder.AppendLine(); // Add an empty line between rebars
        }

        // Show the message box with the rebar information
        TaskDialog.Show("Rebar Info", messageBuilder.ToString());

        return Result.Succeeded;
    }
    catch (Exception ex)
    {
        message = ex.Message;
        return Result.Failed;
    }
}

 

 i don't know what the process of next. please guide me.
Thanks in Advanced


0 Likes
1,201 Views
5 Replies
Replies (5)
Message 2 of 6

naveen.kumar.t
Autodesk Support
Autodesk Support
0 Likes
Message 3 of 6

jeremy_tammik
Alumni
Alumni

How are you planning to use the solid that you generate? Depending on your needs, there may be more efficient solutions.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 6

DesignGroup01
Enthusiast
Enthusiast

Thanks your reply.
My planning is the all rebar check intersect.
first rebar check remaining all rebar, but first rebar not check with it self.

overall my planning the check rebar clash with rebar.

0 Likes
Message 5 of 6

jeremy_tammik
Alumni
Alumni

Oh dear. That is what I feared. Well, trying to convert all rebar to solids, and then performing a Boolean solid collision check on all of those objects will be extremely costly in term of computation time and memory. I would strongly suggest that you think of a more efficient approach. For instance, how about just sticking with the rebar centreline curves and the rebar radii, and checking to ensure that the distance between the curves is greater than the sum opf the radii? I guess that algorithm might save you several orders of magnitude of computation effort. 

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 6

jeremy_tammik
Alumni
Alumni

Note that similar issues have been discussed and similar suggestions given previously here in the forum. Please search for something like "rebar solid":

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes