How to create a sweep with multiple closed loops in profile

How to create a sweep with multiple closed loops in profile

846081597
Enthusiast Enthusiast
2,839 Views
5 Replies
Message 1 of 6

How to create a sweep with multiple closed loops in profile

846081597
Enthusiast
Enthusiast

Hello,i want to create a sweep with multiple closed loops in profile,like this 轮廓1.png

 i can draw the profile on the plane with modleline,but if i using it to creating sweep,it will report errors"can not create sweep" without any other tips, 

And i have created sweeps using profile with two loops successfully like

错误1.png错误2.png

Is there any limitation, for example, the sweep profile can only have two closed loops at most, otherwise it will be wrong?

 

i need your help,thank you.

0 Likes
Accepted solutions (1)
2,840 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

People could help you better if you provided more details, e.g., the method you are calling, the exact error message, the exact loop definitions etc. 

 

The best way to share the complete and exact problem description is often through a minimal reproducible case:

 

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

   

Lacking that info, I can only guess.

  

Maybe the loop orientation is important? Outside loop counterclockwise, inner loops clockwise, inner-inner loops counterclockwise, etc.?

  

Cheers,

  

Jeremy

  



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

0 Likes
Message 3 of 6

846081597
Enthusiast
Enthusiast
 

I'm sorry I've been busy with something else lately, and I can't reply to you until now.

I have wrote a  test code and found that I still couldn't create a sweep with three closed loops. Here's the code:

 

public Sweep CreateSweep_EmptyTest(Autodesk.Revit.ApplicationServices.Application app,Autodesk.Revit.DB.Document doc)
{
CurveArray path = new CurveArray();
path.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 5, 0)));


XYZ p1 = new XYZ(0, 0, 0);
XYZ p2 = new XYZ(10, 0, 0);
XYZ p3 = new XYZ(10, 15, 0);
XYZ p4 = new XYZ(0, 15, 0);
XYZ a1 = new XYZ(1, 5, 0);
XYZ a2 = new XYZ(3, 5, 0);
XYZ a3 = new XYZ(3, 10, 0);
XYZ a4 = new XYZ(1, 10, 0);
XYZ b1 = new XYZ(5, 5, 0);
XYZ b2 = new XYZ(7, 5, 0);
XYZ b3 = new XYZ(7, 10, 0);
XYZ b4 = new XYZ(5, 10, 0);

Sweep sweep = null;
CurveArrArray arrcurve = new CurveArrArray();
CurveArray curve = new CurveArray();
curve.Append(Line.CreateBound(p1, p2));
curve.Append(Line.CreateBound(p2, p3));
curve.Append(Line.CreateBound(p3, p4));
curve.Append(Line.CreateBound(p4, p1));
//curve.Append(Line.CreateBound(a1, a2));
//curve.Append(Line.CreateBound(a2, a3));
//curve.Append(Line.CreateBound(a3, a4));
//curve.Append(Line.CreateBound(a4, a1));
curve.Append(Line.CreateBound(a1, a4));
curve.Append(Line.CreateBound(a4, a3));
curve.Append(Line.CreateBound(a3, a2));
curve.Append(Line.CreateBound(a2, a1));
//curve.Append(Line.CreateBound(b1, b2));
//curve.Append(Line.CreateBound(b2, b3));
//curve.Append(Line.CreateBound(b3, b4));
//curve.Append(Line.CreateBound(b4, b1));
curve.Append(Line.CreateBound(b1, b4));
curve.Append(Line.CreateBound(b4, b3));
curve.Append(Line.CreateBound(b3, b2));
curve.Append(Line.CreateBound(b2, b1));



arrcurve.Append(curve);
SweepProfile profile = m_revit.Create.NewCurveLoopsProfile(arrcurve);
Autodesk.Revit.DB.XYZ normal = Autodesk.Revit.DB.XYZ.BasisZ;
SketchPlane sketchPlane = CreateSketchPlane(normal, XYZ.Zero);
sweep = doc.FamilyCreate.NewSweep(true, path, sketchPlane, profile, 0, ProfilePlaneLocation.Start);
return sweep;
}

 

 

I have run it with these conditions that the square outside is counterclockwise and the inner a is clockwise,the inner b is counterclockwise or the square outside is counterclockwise and the inner a is counterclockwise ,the inner b is clockwise or the square outside is counterclockwise, the inner a and inner b both clockwise,they all failed.

If the inside and outside  are opposite with two closed loops,they can always be successfully.

I can not solve the problem, i need your help,thank you.

 

0 Likes
Message 4 of 6

FAIR59
Advisor
Advisor
Accepted solution

every loop needs to be a separate CurveArray !

CurveArrArray arrcurve = new CurveArrArray();
CurveArray curve = new CurveArray();
curve.Append(Line.CreateBound(p1, p2));
curve.Append(Line.CreateBound(p2, p3));
curve.Append(Line.CreateBound(p3, p4));
curve.Append(Line.CreateBound(p4, p1));
arrcurve.Append(curve);
curve = new CurveArray();
curve.Append(Line.CreateBound(a1, a4));
curve.Append(Line.CreateBound(a4, a3));
curve.Append(Line.CreateBound(a3, a2));
curve.Append(Line.CreateBound(a2, a1));
arrcurve.Append(curve);
curve = new CurveArray();
curve.Append(Line.CreateBound(b1, b4));
curve.Append(Line.CreateBound(b4, b3));
curve.Append(Line.CreateBound(b3, b2));
curve.Append(Line.CreateBound(b2, b1));
arrcurve.Append(curve);
Message 5 of 6

846081597
Enthusiast
Enthusiast

Thank you,you are so kind,my problem has been solved with your help,thank you very much.

0 Likes
Message 6 of 6

jeremytammik
Autodesk
Autodesk

Your help is always much appreciated, @FAIR59, and your answers always great!

 

I promoted this to a blog post for posterity, and added Ariel Chen and your sample code to The Building Coder samples:

 

https://thebuildingcoder.typepad.com/blog/2019/02/creating-a-sweep-with-multiple-closed-loops.html

 

Very many thanks to both of you for raising and solving this.

 

Cheers,

 

Jeremy

 



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

0 Likes