Recent Posts

Pages: 1 ... 5 6 [7] 8 9 10
61
3D entities / Create extruded cylinder
« Last post by fixo on February 19, 2013, 03:20:13 PM »
        [CommandMethod("testCylinder")]
        public void DrawExtrudedCylinder()
        {

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;

            Editor ed = doc.Editor;

            Point3d cp;

            PromptPointOptions ptopts = new PromptPointOptions("\nSelect center point of circel: ");

            PromptPointResult ptres = ed.GetPoint(ptopts);

            // Exit if the user presses ESC or cancels the command
            if (ptres.Status != PromptStatus.OK) return;

            cp = ptres.Value;
            //base point
           
            PromptDistanceOptions pdo = new PromptDistanceOptions("\nEnter a radius: ");
            pdo.AllowNone = true;
            pdo.UseDefaultValue = true;
            pdo.DefaultValue = 100.0;
            pdo.BasePoint = cp;
            pdo.UseBasePoint = true;
            pdo.UseDashedLine = true;
           
            PromptDoubleResult res;
            res = ed.GetDistance(pdo);
            if (res.Status != PromptStatus.OK)
                return;

            double rad = res.Value;

            ed.WriteMessage("\nRadius Entered\t{0}", rad);
            pdo = new PromptDistanceOptions("\nEnter cylinder height: ");
            pdo.AllowNone = true;
            pdo.UseDefaultValue = true;
            pdo.DefaultValue = 1000.0;
            pdo.BasePoint = cp;
            pdo.UseBasePoint = true;
            pdo.UseDashedLine = true;

            res = ed.GetDistance(pdo);
            if (res.Status != PromptStatus.OK)
                return;

            double height = res.Value;
 
            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                Circle circ = new Circle(cp, Vector3d.ZAxis, rad);
               

                BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;

                ObjectId objId = btr.AppendEntity(circ);

                tr.AddNewlyCreatedDBObject(circ, true);

                // Get the boundary curves to create a region
                DBObjectCollection regs = new DBObjectCollection();

                regs.Add(circ);

                // Create a region from the circle.

                DBObjectCollection regions = new DBObjectCollection();

                regions = Region.CreateFromCurves(regs);
               
                if (regions.Count == 0)
                {
                    ed.WriteMessage("\nFailed to create region\n");
                    return;
                }

                Region reg = (Region)regions[0];

                // Extrude the region to create a solid.

                Solid3d sol = new Solid3d();

                sol.RecordHistory = true;// important

                sol.ShowHistory = true;// important

                sol.Extrude(reg, height, 0.0);// < --- set taper angle here

                ObjectId solId = ObjectId.Null;

                solId = btr.AppendEntity(sol);

                tr.AddNewlyCreatedDBObject(sol, true);

                if (!circ.IsWriteEnabled) circ.UpgradeOpen();

                circ.Erase();

                tr.Commit();
            }

        }
62
This site / Re: Welcome on the AutoCAD .NET developer forums
« Last post by cnicho on February 19, 2013, 01:50:13 PM »
Hello All,
I'm still trying to get to grips with AutoCAD .Net development.
Learning C#, WPF, MVVM, AutoCAD 2013 .Net API
Regards
Craig
63
Dimensions / Display sum of selected dimensions
« Last post by fixo on February 15, 2013, 09:30:41 PM »
Code: [Select]
        [CommandMethod("DisplayDimSum", "dds", CommandFlags.Modal | CommandFlags.UsePickSet)]
        public void SumOfDims()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            double sum = 0;
            TypedValue[] values = new TypedValue[] { new TypedValue(0, "DIMENSION") };
            SelectionFilter filter = new SelectionFilter(values);
            PromptSelectionOptions opts = new PromptSelectionOptions();

            opts.MessageForRemoval = "\nMust be a type of Dimension!";
            opts.MessageForAdding = "\nSelect dimensions to reset : ";
            opts.PrepareOptionalDetails = false;
            opts.SingleOnly = false;
            opts.SinglePickInSpace = false;
            opts.AllowDuplicates = true;
            PromptSelectionResult result = ed.GetSelection(opts, filter);
            if (result.Status != PromptStatus.OK) return;

            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    SelectionSet sset = result.Value;
                    foreach (SelectedObject selobj in sset)
                    {
                        DBObject obj = tr.GetObject(selobj.ObjectId, OpenMode.ForWrite, false) as DBObject;
                        Dimension dim = obj as Dimension;

                        if (dim != null)
                        {
                            sum += dim.Measurement;

                        }
                    }

                    tr.Commit();
                }
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(string.Format("Sum of dimensions = {0:f3}", sum));
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("\nProblem with selection dimensions.\n");
                ed.WriteMessage(ex.Message);
            }
        }
64
Layers / Load base or custom linetypes
« Last post by fixo on February 14, 2013, 06:40:08 PM »
This code allow user to load both linetypes from "acad.lin" or "acadiso.lin" file
and from the custom linetype file,
see attachment, both C# and VB.NET code included
65
AutoCAD talk / Re: Autoload dll from a personal folder
« Last post by (gile) on February 13, 2013, 10:29:59 PM »
Hi,

As far as I know, you cannot use the autoloader from a different folder of those provided by Autodesk:
- %appdata%\Autodesk\ApplicationPlugins
- %programfiles%\Autodesk\ApplicationPlugins
- %programdata%\Autodesk\ApplicationPlugins

If you have rights to write in the registry, you can register your application:
http://through-the-interface.typepad.com/through_the_interface/2006/09/automatic_loadi.html
66
AutoCAD talk / Autoload dll from a personal folder
« Last post by madmat on February 13, 2013, 08:30:39 PM »
Hi,

I'm searching how to load my .Net dll via the autoloader method, but from a folder on my d:\ drive (second partition).
I managed to get it loaded from a local path (C:\Program Files\Autodesk\ApplicationPlugins\Capacites.bundle\) with xml file. That works fine.
But at work I'm not administrator anymore, and if I have to copy some files on my hard drive, I have to do it on d:\

So... my question :
Is there any way to tell Autocad to watch any self-defined path at startup for personal plugins, and to load them automatically?
I've tried "Autoloadpath" but it didn't work for me (It's maybe only a path for vba and lisp applications).

Does anybody have an idea?
67
This site / Re: MockFlow is a wireframing suite for user interface design
« Last post by cherly77 on February 13, 2013, 02:12:28 PM »
Excellent forum, Thnkx for uploading the important material. I found it useful. Best regards !!
68
Dimensions / Extend leader to selected curve
« Last post by fixo on February 05, 2013, 11:50:26 AM »
 
Code: [Select]
       [CommandMethod("Lex")]
        public void testLeaderExtend()
        {
            // Get active document and database
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            // Prompt the user to select a leader.
            PromptEntityOptions pso = new PromptEntityOptions("\nPlease select a leader ");
            pso.SetRejectMessage("\nSelect leader only ");
            pso.AddAllowedClass(typeof(Leader), false);
            PromptEntityResult res = ed.GetEntity(pso);
            if (res.Status != PromptStatus.OK) return;
            // Prompt the user to select a curve.
            PromptEntityOptions pno = new PromptEntityOptions("\nPlease select a single curve to extend leader to: ");
            pso.SetRejectMessage("\nSelect curve only ");
            pso.AddAllowedClass(typeof(Curve), false);
            PromptEntityResult nres = ed.GetEntity(pno);
            if (nres.Status != PromptStatus.OK) return;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                // open current space for write to modify leader
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                ObjectId ldid;
                ldid = res.ObjectId;
                ObjectId crid;
                crid = nres.ObjectId;
                Leader leader = tr.GetObject(ldid, OpenMode.ForRead) as Leader;
                if (leader == null) return;
                Point3d arrPt = leader.VertexAt(0);
                ed.WriteMessage("\nPoint on arrow:\t({0:f3}\n", arrPt);
                Curve curv = tr.GetObject(crid, OpenMode.ForRead) as Curve;
                if (curv == null) return;
                // Get point on curve
                Point3d nearPt = curv.GetClosestPointTo(nres.PickedPoint, false).TransformBy(Matrix3d.Identity);
                ed.WriteMessage("\nPoint on line:\t({0:f3}\n", nearPt);
                leader.UpgradeOpen();
                leader.SetVertexAt(0, nearPt);
                leader.RecordGraphicsModified(true);
                // Commit transaction
                tr.Commit();
            }
        }
69
DesignScript / Benefits Of Using Dropshipper Reviews
« Last post by Wholesaler1 on February 03, 2013, 04:08:41 PM »
A dropshipper is a person or company who will earn a commission by passing orders on to the actual manufacturer of a product. Such a person or company can be a retailer or an agent. The goods ordered by the customer will be directly drop shipped from the manufacturer to their home. As a result, the agent will not have to keep diversified stock of the inventory.
70
Tables / Create block table summary
« Last post by fixo on February 03, 2013, 12:48:27 PM »
The code is similar on command ATTOUT,
start command with 'CRAT' in the command line,
please use second attached file, because first one have a bug
when just one block selected on screen
Pages: 1 ... 5 6 [7] 8 9 10