A sample please !

A sample please !

sizy458
Advocate Advocate
304 Views
1 Reply
Message 1 of 2

A sample please !

sizy458
Advocate
Advocate

I find a sample for fix constrainte rebar to other rebar  !

Thank you provide sample  ,

i at all dont understand documentation API !

 

Here my code for fix a constraint of a rebar forme '00' to other rebar forme '00' 'Class Rebar' at 2 inchs THEN it don't work.

 

ANY sample finded !

 

 

public Result Commande4(
      UIApplication uiapp, object model)
        {

            {
                Rebar st = TcmPick.saisiracier(uiapp.ActiveUIDocument, "ttt2");

                {
                    Reference refr = uiapp.ActiveUIDocument.Selection.PickObject(ObjectType.PointOnElement);
                    if (refr != null)
                    {
                        RebarConstraintsManager rbcst = st.GetRebarConstraintsManager();
                        
                        IList<RebarConstrainedHandle> ilhst = rbcst.GetAllConstrainedHandles();
                        foreach (var lil in ilhst)
                        {
                            var cc = lil.GetHandleType();
                            cc = cc;
                        }
                       

                        List<Reference> lrefr = new List<Reference>();
                        lrefr.Add(refr);


                      
                        foreach (RebarConstrainedHandle ilhprx0 in ilhst)
                        {
                            RebarHandleType cc = ilhprx0.GetHandleType();
                           
                            {
                                

                                var Lccl = rbcst.GetConstraintCandidatesForHandle(ilhprx0, refr);
                                if (Lccl.Count == 0)
                                    Lccl = rbcst.GetConstraintCandidatesForHandle(ilhprx0);
                                foreach (RebarConstraint ccl in Lccl)
                                {
                                  
                                    if (ccl.GetConstraintType() == RebarConstraintType.ToOtherRebar)
                                    {
                                        var cttarget = ccl.GetTargetRebarConstraintType();
                                        if ((cttarget != TargetRebarConstraintType.HookBend) && (cttarget != TargetRebarConstraintType.BarBend))
                                        {
                                            ccl.SetDistanceToTargetRebar(0.3048 * 2);
                                            bool capasse = false;
                                            try
                                            {

                                                ccl.ReplaceReferenceTargets(ilhprx0, lrefr, false, 0.3048 * 2);

                                                capasse = true;
                                            }
                                            catch (Exception ee)
                                            {
                                                ee = ee;
                                            }
                                            try
                                            {

                                                ccl.ReplaceReferenceTargets(ilhprx0, lrefr, true, 0.3048 * 2);

                                                capasse = true;
                                            }
                                            catch (Exception ee)
                                            {
                                                ee = ee;
                                            }
                                            if (capasse)
                                            {
                                                capasse = capasse;
                                            }
                                        }
                                    }
                                    
                                }

                                
                            }
                        }
                    }
                }

 

 

 

 

Thank you provide sample.

Thank.

 

 

0 Likes
305 Views
1 Reply
Reply (1)
Message 2 of 2

sizy458
Advocate
Advocate

Code work only forme '00' but to watch ....

 

internal static bool SetHanging1(Rebar st, Rebar prx, double v)
            {
                bool ret = false;
                if (prx != null)
                {
                    RebarConstraintsManager rbcst = st.GetRebarConstraintsManager();
                    
                   
                    IList<RebarConstrainedHandle> ilhst = rbcst.GetAllHandles();
                    
                    
                    foreach (var ilhprx0 in ilhst)
                    {
                      
                        
                        {
                          

                            IList<RebarConstraint> Llcsrc=rbcst.GetConstraintCandidatesForHandle(ilhprx0,prx.Id);
                            RebarConstraint lc1 = null;
                            foreach (var fa1 in Llcsrc)
                            {
                                var cto = fa1.GetConstraintType();
                                //var dbg1 = fdbg1.GetTargetElement();
                                if (cto == RebarConstraintType.ToOtherRebar)
                                {
                                    lc1 = fa1;

                                    

                                    //foreach (var ilhst0 in ilhst)//dest 'st'
                                    {
                                        //var yy = ilhst0.GetHandleType();
                                       
                                        {
                                            //IList<RebarConstraint> Llcdst = rbcst.GetConstraintCandidatesForHandle(ilhst0);  //dest 'st'

                                            //RebarConstraint lc2dest = null;
                                            //foreach (var lc2dest in Llcdst)
                                            {
                                                var ct = fa1.GetConstraintType();
                                                if (ct == RebarConstraintType.ToOtherRebar)
                                                {
                                                    TargetRebarConstraintType cttarget = fa1.GetTargetRebarConstraintType();
                                                    if ((cttarget == TargetRebarConstraintType.Edge))   
                                                    {
                                                        // lc2dest = fdbg2;
#if v2020
                                                        fa1.SetDistanceToTargetRebar(v);
                                                        rbcst.SetPreferredConstraintForHandle(ilhprx0, fa1);
                                                        ret = true;
#endif
                                                    }
                                                }
                                                
                                            }
                                            

                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (!ret)
                {
                    
                }
                        
                return ret;

            }

 

0 Likes