Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Close

DesignScript

- Autodesk Community
- >
- Archived Forums
- >
- Autodesk Labs
- >
- DesignScript
- >
- Re: Moebius Strip: My first attempt

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

818 Views, 8 Replies

10-20-2012 05:41 AM

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.

2
Kudos

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-20-2012 01:16 PM in reply to:
jwagner

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

1
Kudo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-21-2012 01:52 AM in reply to:
luke

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

0
Kudos

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-21-2012 02:01 AM in reply to:
jwagner

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] });

Gilles Chanteau

1
Kudo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-21-2012 02:02 AM in reply to:
jwagner

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.

0
Kudos

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-08-2012 12:41 AM in reply to:
jwagner

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.

0
Kudos

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-14-2012 07:52 PM in reply to:
jwagner

NICE WORK!

THANK YOU FOR SHARING!

0
Kudos

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-23-2013 05:11 PM in reply to:
pointclouding

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]);

Gilles Chanteau

0
Kudos

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-04-2013 06:54 AM in reply to:
_gile

Thanks for sharing. This is what technology previews are all about.

Program Manager

Autodesk Labs

Autodesk, Inc.

0
Kudos

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements

Autodesk Labs is home for new prototypes, experiments, applications, and technologies.

Start with some of our most frequented solutions to get help installing your software.

Upgrading to a 2015 product? Make sure to check these out 1st!

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.