Author Topic: Mobius strip in AutoCAD 2008 or 2009 by C#  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

ahlzl

  • Guest
Mobius strip in AutoCAD 2008 or 2009 by C#
« on: September 24, 2008, 12:28:34 AM »
thank the people who helped me !
Code: [Select]
using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

namespace CsTemp
{
    public class Class1
    {
        [CommandMethod("Test")]
        public void Test()
        {
            Circle circle1 = new Circle(new Point3d(0, 0, 0), new Vector3d(0, 0, 1), 5);
            Line line1 = new Line(new Point3d(5, 0, 0), new Point3d(5, 0, 1));

            SweepOptionsBuilder swOptBu = new SweepOptionsBuilder();
            swOptBu.TwistAngle = 2 * Math.PI;
            SweepOptions swOpt = swOptBu.ToSweepOptions();

            SweptSurface swSur = new SweptSurface();
            swSur.CreateSweptSurface(line1, circle1, swOpt);

            Solid3d solid3dEnt = swSur.Thicken(0.2, true);
            AppendEntity(solid3dEnt);
        }

        private ObjectId AppendEntity(Entity ent)
        {
            ObjectId entId;
            Database db = HostApplicationServices.WorkingDatabase;
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId,
                    OpenMode.ForRead);
                BlockTableRecord btr = (BlockTableRecord)trans.GetObject
                    (bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                entId = btr.AppendEntity(ent);
                trans.AddNewlyCreatedDBObject(ent, true);
                trans.Commit();
            }
            return entId;
        }
    }
}

MickD

  • Gator
  • Posts: 3420
  • (x-in)->[process]->(y-out)
Re: Mobius strip in AutoCAD 2008 or 2009 by C#
« Reply #1 on: September 24, 2008, 01:59:14 AM »
Very cool!
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

jnieman

  • Guest
Re: Mobius strip in AutoCAD 2008 or 2009 by C#
« Reply #2 on: September 24, 2008, 08:50:21 AM »
Not to be a picker of nits, but that isn't actually a mobius strip.

If you follow one face of the solid, you never end up on the "other" side of it.  It has two clear faces opposing eachother.

A mobius strip, if you were to follow your finger down the main face, you would end up on the opposite side of the object from where you started with your finger, until you went around it again.... meaning it "somewhat" has "one" continuous side, rather than two.

Your solid has two.

Ref:

If you follow along the object, down a face, you'll notice you go along both sides of the paper by the time you end up at your origin.

Some reason that doesn't happen when I follow yours.

Never the less... getting past the nits.  That's awesome!  Great sweep control expressed there.  Very interesting!

jnieman

  • Guest
Re: Mobius strip in AutoCAD 2008 or 2009 by C#
« Reply #3 on: September 24, 2008, 08:53:54 AM »
Not entirely sure, but it could be because it seems that your object is taking TWO twists, rather than one, see below:

So maybe it's just a case of doing a job TOO well :P

ahlzl

  • Guest
Re: Mobius strip in AutoCAD 2008 or 2009 by C#
« Reply #4 on: September 24, 2008, 09:34:31 PM »
thank you, jnieman. look……

jnieman

  • Guest
Re: Mobius strip in AutoCAD 2008 or 2009 by C#
« Reply #5 on: September 25, 2008, 08:50:22 AM »
thank you, jnieman. look……


That's the ticket

ahlzl

  • Guest
Re: Mobius strip in AutoCAD 2008 or 2009 by C#
« Reply #6 on: September 29, 2008, 04:16:47 AM »
hehe

jjs

  • Guest
Re: Mobius strip in AutoCAD 2008 or 2009 by C#
« Reply #7 on: October 06, 2008, 11:53:33 AM »
so where is the revised code?