DesignScript
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
My first attempt in DesignScript.
import("ProtoGeometry.dll");
import("Math.dll");
num_pts = 100;
s = 20;
t = 0..360..#num_pts;
R = 100;
x = (R + s * (Math.Cos(t / 2))) * (Math.Cos(t));
y = (R + s * (Math.Cos(t / 2))) * (Math.Sin(t));
z = s * Math.Sin(t / 2);
p1 = Point.ByCoordinates(x, y, z);
int_curve = BSplineCurve.ByControlVertices(p1,1);
int_curve.Color = Color.ByARGB(255, 0, 0, 255);
s2 = -20;
t2 = t;
R2 = R;
x2 = (R2 + s2 * (Math.Cos(t2 / 2))) * (Math.Cos(t2));
y2 = (R2 + s2 * (Math.Cos(t2 / 2))) * (Math.Sin(t2));
z2 = s2 * Math.Sin(t2 / 2);
p2 = Point.ByCoordinates(x2, y2, z2);
//x = print(x,y,z);
int_curve2 = BSplineCurve.ByControlVertices(p2,1);
int_curve2.Color = Color.ByARGB(255, 0, 255, 0);
l[1..num_pts] = Line.ByStartPointEndPoint(p1, p2);
loft = Surface.LoftFromCrossSections({ l[1..(num_pts-1)] });
http://inventorfaq.blogspot.de/2012/10/mobius-band
Juergen
Solved! Go to Solution.
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Dear Jurgen,
This is really great to see ![]()
If I might make a few suggestions?
We can adjust this line
>l[1..num_pts] = Line.ByStartPointEndPoint(p1, p2);
to be
l = Line.ByStartPointEndPoint(p1, p2);
and designScript will just turn l into a collection automatically. This also means that we can avoid the 'first element is null' problem
and then the next line becomes:
loft = Surface.LoftFromCrossSections({ l[0..num_pts - 2], l[1..num_pts - 1] });
Which is a list of things to loft from -> to. It seems perhaps the arguments of this method could do with a bit more explaining?
But - this gives the complete script as:
//=====
import("ProtoGeometry.dll");
import("Math.dll");
num_pts = 100;
s = 20;
t = 0..360..#num_pts;
R = 100;
x = (R + s * (Math.Cos(t / 2))) * (Math.Cos(t));
y = (R + s * (Math.Cos(t / 2))) * (Math.Sin(t));
z = s * Math.Sin(t / 2);
p1 = Point.ByCoordinates(x, y, z);
int_curve = BSplineCurve.ByControlVertices(p1,1);
int_curve.Color = Color.ByARGB(255, 0, 0, 255);
s2 = -20;
t2 = t;
R2 = R;
x2 = (R2 + s2 * (Math.Cos(t2 / 2))) * (Math.Cos(t2));
y2 = (R2 + s2 * (Math.Cos(t2 / 2))) * (Math.Sin(t2));
z2 = s2 * Math.Sin(t2 / 2);
p2 = Point.ByCoordinates(x2, y2, z2);
//x = print(x,y,z);
int_curve2 = BSplineCurve.ByControlVertices(p2,1);
int_curve2.Color = Color.ByARGB(255, 0, 255, 0);
l = Line.ByStartPointEndPoint(p1, p2);
loft = Surface.LoftFromCrossSections({ l[0..num_pts - 2], l[1..num_pts - 1] });
//=====
Which produces a complete mobius band. Is that what you were aiming for?
On another note - I see in your blog, you say DesignScript crashes often. I'm sorry to hear that. Could you send me a screenshot? We're aware of one crashing bug, but I'd like to make sure there isn't something else we've missed.
Thanks again - this is a great start and a lovely little script ![]()
Luke
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Luke,
thank you for your help to complete the script. Works great!
And because of teh crash: I get a crash after runing a script many times. Error:
but: I don't have SP1 für ACAD Mechanical 2013 installed! Will install today.
In addition to your improvement I have made this change to the script:
s2 = s * -1;
because s2 must be -s ![]()
This is my final script with your improvements:
import("ProtoGeometry.dll");
import("Math.dll");
num_pts = 100;
s = 20;
t = 0..360..#num_pts;
R = 100;
x = (R + s * (Math.Cos(t / 2))) * (Math.Cos(t));
y = (R + s * (Math.Cos(t / 2))) * (Math.Sin(t));
z = s * Math.Sin(t / 2);
p1 = Point.ByCoordinates(x, y, z);
int_curve = BSplineCurve.ByControlVertices(p1,1);
int_curve.Color = Color.ByARGB(255, 0, 0, 255);
s2 = s * -1;
t2 = t;
R2 = R;
x2 = (R2 + s2 * (Math.Cos(t2 / 2))) * (Math.Cos(t2));
y2 = (R2 + s2 * (Math.Cos(t2 / 2))) * (Math.Sin(t2));
z2 = s2 * Math.Sin(t2 / 2);
p2 = Point.ByCoordinates(x2, y2, z2);
//x = print(x,y,z);
int_curve2 = BSplineCurve.ByControlVertices(p2,1);
int_curve2.Color = Color.ByARGB(255, 0, 255, 0);
l= Line.ByStartPointEndPoint(p1, p2);
loft = Surface.LoftFromCrossSections({ l[0..num_pts - 2], l[1..num_pts - 1] });
Thanks again!
Juergen
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
Very nice.
My 2 cts: the point collections can be computed by a single function which argument is s or -s (I removed the splines as they're not used to build the surfaces)
import("ProtoGeometry.dll");
import("Math.dll");
num_pts = 100;
s = 20;
t = 0..360..#num_pts;
R = 100;
def pts(s : double)
{
x = (R + s * (Math.Cos(t / 2))) * (Math.Cos(t));
y = (R + s * (Math.Cos(t / 2))) * (Math.Sin(t));
z = s * Math.Sin(t / 2);
return = Point.ByCoordinates(x, y, z);
}
l = Line.ByStartPointEndPoint(pts(s), pts(-s));
loft = Surface.LoftFromCrossSections({ l[0..num_pts - 2], l[1..num_pts - 1] });
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
because of the crash: When I shade the drawing und run the script again (1-2 times) I get the system error.
Same problem after applying SP1 for AutoCAD Mechanical 2013.
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sorry to know that you are facing some crash while running design script. A new update (version 0.3.24.5026) for DesignScript is available, hopefully this update fixes your crash issue.
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
NICE WORK!
THANK YOU FOR SHARING!
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Playing with this in .NET at TheSwamp, it looks like we (kaefer and I) found a way to create a single closed entity (Solid3d)
import("ProtoGeometry.dll");
import("Math.dll");
numPts = 60;
halfWid = 20;
angle = 0..360..#numPts;
radius = 100;
width = 2;
def pts(halfWid : double)
{
x = (radius + halfWid * (Math.Cos(angle / 2))) * (Math.Cos(angle));
y = (radius + halfWid * (Math.Cos(angle / 2))) * (Math.Sin(angle));
z = halfWid * Math.Sin(angle / 2);
return = Point.ByCoordinates(x, y, z);
}
lines = Line.ByStartPointEndPoint(pts(halfWid), pts(-halfWid));
lines.SetVisibility(false);
surfs = Surface.LoftFromCrossSections({ lines[0..numPts / 2], lines[numPts / 2..numPts] });
surfs.Visible = false;
solids = surfs.Thicken(width, true);
solid = solids[0].Union(solids[1]);
Re: Moebius Strip: My first attempt
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for sharing. This is what technology previews are all about.

Scott Sheppard
Program Manager
Autodesk Labs
Autodesk, Inc.
