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
Link copied