Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy a rebar shape 77

2 REPLIES 2
Reply
Message 1 of 3
sizy458
561 Views, 2 Replies

Copy a rebar shape 77

Hello ,

this code for remove and recreate rebar work but

it's don't work with rebarshape '77'

 

I should delete and recreate entity of rebarshape '77'

 

Code:

public Result Commande5(
       UIApplication uiapp, object model)
        {
            
            {

                var rborg = TcmPick.saisiracier(uiapp.ActiveUIDocument, "ttt2"); ///Work !
                Document doc = rborg.Document;

                Transaction trans;
                trans = new Transaction(doc);
                trans.Start("delrebar");

                var cx = HelperRevit1.RevitHelper_GetComputeDriving(rborg).ToList();
                var normal = HelperRevit1.HelperRevit_GetNormalRebar(rborg);
                var shapeid = HelperRevit1.HelperRevit_GetShapeID(rborg);
                var rbshape = doc.GetElement(shapeid) as RebarShape;
               

                var start = rborg.GetHookTypeId(0);
                var end = rborg.GetHookTypeId(1);
                RebarHookType startHook = null, endHook = null;
                if (start != null)
                    startHook = doc.GetElement(start) as RebarHookType;
                if (end != null)
                    endHook = doc.GetElement(end) as RebarHookType;
                var startHookOrient = rborg.GetHookOrientation(0);
                var endHookOrient = rborg.GetHookOrientation(1);

                var rbbtype = doc.GetElement(rborg.GetTypeId()) as RebarBarType;

                ElementId hostId = rborg.GetHostId();
                doc.Delete(rborg.Id);
                trans.Commit();


                trans = new Transaction(doc);
                trans.Start("addrebar");
                var host = doc.GetElement(hostId);

                var rbdst = Rebar.CreateFromCurvesAndShape(doc, rbshape, rbbtype, startHook, endHook, host, normal, cx, startHookOrient, endHookOrient);
               
                //rbdst.RebarShapeId = shape77.Id;
                trans.Commit();
                // testinternet(uiapp, model);
                return Result.Succeeded;
            }


 internal static IList<Curve> RevitHelper_GetComputeDriving(Rebar rb)
        {
#if v2019
            RebarShapeDrivenAccessor rbaccessor;
            rbaccessor=rb.GetShapeDrivenAccessor();
#endif
#if v2019
            return rbaccessor.ComputeDrivingCurves();
#else
            return rb.ComputeDrivingCurves();
#endif         
        }

 internal static XYZ HelperRevit_GetNormalRebar(Rebar rb)
        {
#if v2019
            RebarShapeDrivenAccessor rbaccessor;
            rbaccessor=rb.GetShapeDrivenAccessor();
            return rbaccessor.Normal;
#else
            return rb.Normal;
#endif

        }

   internal static ElementId HelperRevit_GetShapeID(Rebar rb)
        {
#if v2019
           return rb.GetShapeId();
#else
            return rb.RebarShapeId;
#endif
        }

 

Thank

Tags (4)
2 REPLIES 2
Message 2 of 3
jeremytammik
in reply to: sizy458

Dear Sizy,

 

Sorry, that nobody has been able to help you so far. I don't know either, so I passed on your query to the Revit Structural development team. 

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3
jeremytammik
in reply to: sizy458

The development team replied:

 

Please provide a complete minimal reproducible case for deeper analysis:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Rebar shape 77 looks like a spiral which means it is a 3d shape. The method  Rebar.CreateFromCurvesAndShape works only with planar curves. This means that the 3d rebars can’t be created with this method.  You should use Rebar.CreateFromRebarShape for that. We also have a sample which does this, c.f. the NewRebar folder  and search for RebarShapeDefinitionByArcType.Spiral.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report