Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SEANT

Pages: [1]
1
3D entities / Re: Ellipsoid Solid
« on: December 23, 2011, 08:27:05 AM »
By the way: I've changed the command name to "EllipsoidSolid" (or "ElSol", for short) to avoid conflicts.

2
3D entities / Re: Ellipsoid Solid
« on: December 23, 2011, 08:14:21 AM »
The approaching holiday generates numerous distractions. :tresetonne:

Welcome to AcadNETwork, Marko,  and the .NET world at large.

3
AutoCAD talk / Re: What will happen for AutoCAD august 16 2011?
« on: August 16, 2011, 09:47:28 PM »
. . . .

A confirmation to a Autodesk/Microsoft commitment . . . .

I guess I was way off on that one.  They do seem to be committing heavily to hype, though.

4
AutoCAD talk / Re: What will happen for AutoCAD august 16 2011?
« on: August 07, 2011, 07:36:56 PM »
I voted for "AutoCAD on the cloud" but I think it will be more like Extended design collaboration tools – highly customizable – based on Windows Azure.

A confirmation to a Autodesk/Microsoft commitment - for what its worth.

5
3D entities / Re: Ellipsoid Solid
« on: March 04, 2011, 11:29:32 AM »
It doesn't look like my DWG example attachment made it through.  I'll try a second time

6
3D entities / Ellipsoid Solid
« on: March 04, 2011, 11:27:42 AM »
I’m investigating a method for sculpting solids with surface entities for a ‘work in progress’ routine that I have posted over at swamp.org.  The routine posted below served as an early test-bed, and I think it could serve as a good intermediate level “3D Entities” example here as well.

This is definitely a ‘no frills’ routine.  It’s only objective is to place an ellipsoid of specified dimensions at the WCS origin.   Though not generally in high demand, an ellipsoid is a tricky shape to make as a 3dSolid, so this routine has some measure of practicality. 

An added benefit to the method I used was that it imbued the shape with snapable quadrants (via END osnap).

The method, though, has the drawback that it uses objects available only in AutoCAD 2011.

DWG example of outout.

Code: [Select]


using System;
using System.IO;
using System.Collections.Generic;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Windows;


[CommandMethod("Ellipsoid")]
        //Basic method to put an ellipsoid at WCS origin
        static public void OpInitEl()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptDoubleOptions pdo = new PromptDoubleOptions("\nEnter Length ");
            pdo.AllowArbitraryInput = true;
            pdo.AllowNegative = false;
            PromptDoubleResult pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK || pdr.Value <= 0) return;
            double Length = pdr.Value;

            pdo.Message = " Enter Width";
            pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK || pdr.Value <= 0) return;
            double Width = pdr.Value;

            pdo.Message = " Enter Height";
            pdr = ed.GetDouble(pdo);
            if (pdr.Status != PromptStatus.OK || pdr.Value <= 0) return;
            double Height = pdr.Value;

            Double[] matarr = new Double[16]{Length/2, 0.0,0.0,0.0,
                                                0.0,Width/2,0.0,0.0,
                                                0.0,0.0,Height/2,0.0,
                                                0.0,0.0,0.0,1.0};

            Matrix3d mat = new Matrix3d(matarr);

            Point3dCollection Cvs = GenCVs();

            //Scale points from sphere to ellipsoid
            for (int i = 0; i < 9; i++ )
            {
                Cvs[i] = Cvs[i].TransformBy(mat); 
            }
            DoubleCollection Dc = GenWghts();
            KnotCollection[] Knots = GenKnots();
            Database db = HostApplicationServices.WorkingDatabase;
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr = (BlockTableRecord)(trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite));
                try
                {
                    //Generate the ellipsoid Octant
                    Autodesk.AutoCAD.DatabaseServices.NurbSurface NS = new Autodesk.AutoCAD.DatabaseServices.NurbSurface
                        (2, 2, true, 3, 3, Cvs, Dc,
                        Knots[0], Knots[1]);

                    //Create, mirror and union
                    Solid3d sol = new Solid3d();
                    sol.CreateBox(Length, Width, Height);
                    sol.TransformBy(Matrix3d.Scaling(0.5, new Point3d(Length / 2.0, Width / 2.0, Height / 2.0)));
                    sol.Slice(NS);

                    NS.Dispose();//Perhaps not specifically necessary - as NS is transaction resident
                    Plane Mir = new Plane(new Point3d(), new Vector3d(1.0,0.0,0.0));
                    Solid3d solMirr = sol.GetTransformedCopy(Matrix3d.Mirroring(Mir)) as Solid3d;
                    sol.BooleanOperation(BooleanOperationType.BoolUnite, solMirr);

                    Mir = new Plane(new Point3d(), new Vector3d(0.0, 1.0, 0.0));
                    solMirr = sol.GetTransformedCopy(Matrix3d.Mirroring(Mir)) as Solid3d;
                    sol.BooleanOperation(BooleanOperationType.BoolUnite, solMirr);

                    Mir = new Plane(new Point3d(), new Vector3d(0.0, 0.0, 1.0));
                    solMirr = sol.GetTransformedCopy(Matrix3d.Mirroring(Mir)) as Solid3d;
                    sol.BooleanOperation(BooleanOperationType.BoolUnite, solMirr);

                    sol.SetDatabaseDefaults();
                    btr.AppendEntity(sol);
                    trans.AddNewlyCreatedDBObject(sol, true);
                    trans.Commit();
                }
                catch
                {
                    trans.Abort();
                }
            }
        }

        private static Point3dCollection GenCVs()
        {
            //Generate Control Vertices for one octant of nurb based sphere
            Point3dCollection tempPts = new Point3dCollection();
            tempPts.Add(new Point3d(1.0, 0.0, 0.0));
            tempPts.Add(new Point3d(1.0, 0.0, 1.0));
            tempPts.Add(new Point3d(0.0, 0.0, 1.0));

            tempPts.Add(new Point3d(1.0, 1.0, 0.0));
            tempPts.Add(new Point3d(1.0, 1.0, 1.0));
            tempPts.Add(new Point3d(0.0, 0.0, 1.0));

            tempPts.Add(new Point3d(0.0, 1.0, 0.0));
            tempPts.Add(new Point3d(0.0, 1.0, 1.0));
            tempPts.Add(new Point3d(0.0, 0.0, 1.0));

            return tempPts;
        }

        private static DoubleCollection GenWghts()
        {
            //Generate weights for rational nurb surface
            DoubleCollection temp = new DoubleCollection(9);
            Double NearCorner = Math.Sqrt(0.5);

            temp.Add(1.0);
            temp.Add(NearCorner);
            temp.Add(1.0);

            temp.Add(NearCorner);
            temp.Add(0.5);
            temp.Add(NearCorner);

            temp.Add(1.0);
            temp.Add(NearCorner);
            temp.Add(1.0);

            return temp;
           
        }

        private static KnotCollection[] GenKnots()
        {
            //Generate knot vectors for PI based paramatization - uniform span from 0 to Pi/2 in U
            //                                                  - uniform span from 0 to Pi/2 in V
            KnotCollection[] tempKnots = new KnotCollection[2];

            tempKnots[0] = new KnotCollection();
            tempKnots[0].Add(0.0);
            tempKnots[0].Add(0.0);
            tempKnots[0].Add(0.0);

            tempKnots[0].Add(Math.PI / 2);
            tempKnots[0].Add(Math.PI / 2);
            tempKnots[0].Add(Math.PI / 2);

            tempKnots[1] = new KnotCollection();
            tempKnots[1].Add(0.0);
            tempKnots[1].Add(0.0);
            tempKnots[1].Add(0.0);

            tempKnots[1].Add(Math.PI / 2);
            tempKnots[1].Add(Math.PI / 2);
            tempKnots[1].Add(Math.PI / 2);

            return tempKnots;
        }

 

7
AutoCAD talk / Re: Programming languages and AutoCAD
« on: December 03, 2010, 02:20:46 PM »
As a draftsman I’d have to agree with quite a bit of what you said.  Generally,  a well qualified AutoLisp programmer would have a CAD related routine up and running in less time than a comparable .NET effort.   

If we expand the scope beyond that of just the Cad operator, though, to everyone that has a stake in the design information (accounting, marketing, etc.) then we may find that a multi-conduit automation project via AutoLisp is not so efficient.  I suspect this is the level at which .NET languages start to shine.  I may even suggest that, at this “enterprise wide” scope, .Net is at the highest viable programming level.
   
Allocation of resources is another concept that should be explored further; specifically with regard to Autodesk.  As you’ve mentioned, the AutoCAD application engineers have concerns that may not be applicable to the Lisp programmer (speed, security, etc) which justify the use of a very low level language.  New feature (often referred to as “bloat”) are most popular when they have minimal impact on limited system resources.   One of the nice aspects of .NET is the ease at which these low level C++ objects can be exposed.  Given that the programming resources at Autodesk are also limited, more can be offered for less with .NET.   Even though AutoLisp may eventually automate some specific task with 75% fewer lines of code, it may have to wait several releases for the opportunity.

Pages: [1]