Author Topic: Draw Multi-line without jig?  (Read 4588 times)

0 Members and 1 Guest are viewing this topic.

josano

  • Guest
Draw Multi-line without jig?
« on: October 15, 2010, 03:02:25 PM »
Hello Friends,

I was looking for information on how to draw lines without jig.
Unfortunately, I can not find information.
My idea is to draw an example profile metallic as the photo attached.
My idea is more or less what the post code http://www.theswamp.org/index.php?topic=34430.0, only without jig.
Has anyone thought of anything like that or know where can I start?
Something like clicking the start / end point and generate the lines
Thanks guys for the help.

Hugs,
Josano

fixo

  • Guest
Re: Draw Multi-line without jig?
« Reply #1 on: October 16, 2010, 04:36:41 PM »

josano

  • Guest
Re: Draw Multi-line without jig?
« Reply #2 on: October 18, 2010, 03:52:31 PM »
Hi Fixo,

I see the Thread, greatly helped in ideas.
I created a code that adds only three lines that all lines are placed one above the other, could not change the starting point of lines 2 and 3.
Friends, how do I change? I put comments on lines of points.

Hugs,
Josano

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcDb = Autodesk.AutoCAD.DatabaseServices.TransactionManager;

namespace ClassLibrary9
{
    public class Class1
    {
        [CommandMethod("ssa")]
        public static void GetPointsFromUser()
        {
            // le o banco de dados corrente e inicia o gerenciador de transações
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            PromptPointResult pPtRes;
            PromptPointOptions pPtOpts = new PromptPointOptions("");

            // Mensagem para ponto inicial
            pPtOpts.Message = "\nSelecione o ponto inicial da linha: ";
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptStart = pPtRes.Value;

            // Se o usuario pressionar esc ou cancelar o comando sai
            if (pPtRes.Status == PromptStatus.Cancel) return;

            // Mensagem para ponto final
            pPtOpts.Message = "\nSelecione o ponto final da linha: ";
            pPtOpts.UseBasePoint = true;
            pPtOpts.BasePoint = ptStart;
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptEnd = pPtRes.Value;

            if (pPtRes.Status == PromptStatus.Cancel) return;

            // Inicia a transação
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl;
                BlockTableRecord acBlkTblRec;

                // Abre o model space para escrever
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;

                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

                // Criar linhas
                Line acline1 = new Line(ptStart, ptEnd);
             // acline1.Layer = "CT4";
                Line acline2 = new Line(ptStart, ptEnd); //I can not move the line two for the starting point of subtracted 44.7
                Line acline3 = new Line(ptStart, ptEnd); //I can not move the line two for the starting point subtracted from 51


                acline1.SetDatabaseDefaults();
                acline2.SetDatabaseDefaults();
                acline3.SetDatabaseDefaults();
                // Adicionar as linhas ao desenho
                acBlkTblRec.AppendEntity(acline1);
                acBlkTblRec.AppendEntity(acline2);
                acBlkTblRec.AppendEntity(acline3);
                acTrans.AddNewlyCreatedDBObject(acline1, true);
                acTrans.AddNewlyCreatedDBObject(acline2, true);
                acTrans.AddNewlyCreatedDBObject(acline3, true);
                // Confirma as alterações
                acTrans.Commit();
            }
        }
    }
}

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Draw Multi-line without jig?
« Reply #3 on: October 18, 2010, 04:19:23 PM »
How are you subtracting or what are you subtracting?


josano

  • Guest
Re: Draw Multi-line without jig?
« Reply #4 on: October 18, 2010, 04:38:40 PM »
I want to create three lines
a point which has been clicked a 44.7 below and 51 below the other first, always having as reference the first

--------------------------- (Line 1) - reference to the following two lines

--------------------------- (Line 2)
--------------------------- (Line 3)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Draw Multi-line without jig?
« Reply #5 on: October 18, 2010, 06:12:18 PM »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

josano

  • Guest
Re: Draw Multi-line without jig?
« Reply #6 on: October 19, 2010, 03:30:48 PM »
Friends,

Can any of you help me with the code below?
I can insert a bracket of 51 mm x 6.3 mm horizontally.
If I try to enter angle values are not correct.
How can I leave the values prevail even with angle?

Hugs,
Josano

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcDb = Autodesk.AutoCAD.DatabaseServices.TransactionManager;

namespace ClassLibrary9
{
    public class Class1
    {
        [CommandMethod("ssa")]
        public static void GetPointsFromUser()
        {
            // le o banco de dados corrente e inicia o gerenciador de transações
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            PromptPointResult pPtRes;
            PromptPointOptions pPtOpts = new PromptPointOptions("");

            // Mensagem para ponto inicial
            pPtOpts.Message = "\nSelecione o ponto inicial da linha: ";
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptStart = pPtRes.Value;

            // Se o usuario pressionar esc ou cancelar o comando sai
            if (pPtRes.Status == PromptStatus.Cancel) return;

            // Mensagem para ponto final
            pPtOpts.Message = "\nSelecione o ponto final da linha: ";
            pPtOpts.UseBasePoint = true;
            pPtOpts.BasePoint = ptStart;
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptEnd = pPtRes.Value;

            if (pPtRes.Status == PromptStatus.Cancel) return;

            // Inicia a transação
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl;
                BlockTableRecord acBlkTblRec;

                // Abre o model space para escrever
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;

                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

 
                Line acline1 = new Line(ptStart, ptEnd);
                Line acline2 = new Line(ptStart, ptEnd);
                Line acline3 = new Line(ptStart, ptEnd);
                acline2.StartPoint = new Point3d(acline2.StartPoint.X , acline2.StartPoint.Y - 44.7, 0);
                acline2.EndPoint = new Point3d(acline2.EndPoint.X , acline2.EndPoint.Y - 44.7, 0);
                acline3.StartPoint = new Point3d(acline3.StartPoint.X , acline3.StartPoint.Y - 51, 0);
                acline3.EndPoint = new Point3d(acline3.EndPoint.X , acline3.EndPoint.Y - 51, 0);


                acline1.SetDatabaseDefaults();
                acline2.SetDatabaseDefaults();
                acline3.SetDatabaseDefaults();
                // Adicionar as linhas ao desenho
                acBlkTblRec.AppendEntity(acline1);
                acBlkTblRec.AppendEntity(acline2);
                acBlkTblRec.AppendEntity(acline3);
                acTrans.AddNewlyCreatedDBObject(acline1, true);
                acTrans.AddNewlyCreatedDBObject(acline2, true);
                acTrans.AddNewlyCreatedDBObject(acline3, true);
                // Confirma as alterações
                acTrans.Commit();
            }
        }
    }
}
« Last Edit: October 21, 2010, 09:52:07 AM by josano »

josano

  • Guest
Re: Draw Multi-line without jig?
« Reply #7 on: October 22, 2010, 02:50:33 PM »
Friends,

I made some modifications to the code with the tips.
I can now insert with angle but for some reason the values are only correct when I insert horizontally.
Below the code changed, some of you know where I could be wrong?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcDb = Autodesk.AutoCAD.DatabaseServices.TransactionManager;
namespace ClassLibrary9
{
    public class Class1
    {
        [CommandMethod("ssa")]
        public static void GetPointsFromUser()
        {
            // le o banco de dados corrente e inicia o gerenciador de transações
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
           
            PromptPointResult pPtRes;
            PromptPointOptions pPtOpts = new PromptPointOptions("");
            // Mensagem para ponto inicial
            pPtOpts.Message = "\nSelecione o ponto inicial da linha: ";
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Matrix3d UCS = acDoc.Editor.CurrentUserCoordinateSystem;
            Point3d ptStart = pPtRes.Value.TransformBy(UCS);
            // Se o usuario pressionar esc ou cancelar o comando sai
            if (pPtRes.Status == PromptStatus.Cancel) return;
            // Mensagem para ponto final
            pPtOpts.Message = "\nSelecione o ponto final da linha: ";
            pPtOpts.UseBasePoint = true;
            pPtOpts.BasePoint = ptStart;
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptEnd = pPtRes.Value;
            if (pPtRes.Status == PromptStatus.Cancel) return;
            // Inicia a transação
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl;
                BlockTableRecord acBlkTblRec;
                // Abre o model space para escrever
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;
                PromptAngleOptions angOpts = new PromptAngleOptions("\nSelecione o angulo...");
                angOpts.BasePoint = ptStart;
                PromptDoubleResult angRes = acDoc.Editor.GetAngle(angOpts);
 
                Line acline1 = new Line(ptStart, ptEnd);
                acline1.Layer = "CT4";
                Line acline2 = new Line(ptStart, ptEnd);
                acline2.Layer = "TR2";
                Line acline3 = new Line(ptStart, ptEnd);
                acline3.Layer = "CT4";
                acline2.StartPoint = new Point3d(acline2.StartPoint.X , acline2.StartPoint.Y - 44.7, 0);
                acline2.EndPoint = new Point3d(acline2.EndPoint.X , acline2.EndPoint.Y - 44.7, 0);
                acline3.StartPoint = new Point3d(acline3.StartPoint.X , acline3.StartPoint.Y - 51, 0);
                acline3.EndPoint = new Point3d(acline3.EndPoint.X , acline3.EndPoint.Y - 51, 0);
               
                acline1.SetDatabaseDefaults();
                acline2.SetDatabaseDefaults();
                acline3.SetDatabaseDefaults();
                // Adicionar as linhas ao desenho
                acBlkTblRec.AppendEntity(acline1);
                acBlkTblRec.AppendEntity(acline2);
                acBlkTblRec.AppendEntity(acline3);
                acTrans.AddNewlyCreatedDBObject(acline1, true);
                acTrans.AddNewlyCreatedDBObject(acline2, true);
                acTrans.AddNewlyCreatedDBObject(acline3, true);
                // Confirma as alterações
                acTrans.Commit();
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcDb = Autodesk.AutoCAD.DatabaseServices.TransactionManager;

namespace ClassLibrary9
{
    public class Class1
    {
        [CommandMethod("ssa")]
        public static void GetPointsFromUser()
        {
            // le o banco de dados corrente e inicia o gerenciador de transações
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            PromptPointResult pPtRes;
            PromptPointOptions pPtOpts = new PromptPointOptions("");

            // Mensagem para ponto inicial
            pPtOpts.Message = "\nSelecione o ponto inicial da linha: ";
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Matrix3d UCS = acDoc.Editor.CurrentUserCoordinateSystem;
            Point3d ptStart = pPtRes.Value.TransformBy(UCS);

            // Se o usuario pressionar esc ou cancelar o comando sai
            if (pPtRes.Status == PromptStatus.Cancel) return;

            // Mensagem para ponto final
            pPtOpts.Message = "\nSelecione o ponto final da linha: ";
            pPtOpts.UseBasePoint = true;
            pPtOpts.BasePoint = ptStart;
            pPtRes = acDoc.Editor.GetPoint(pPtOpts);
            Point3d ptEnd = pPtRes.Value;

            if (pPtRes.Status == PromptStatus.Cancel) return;

            // Inicia a transação
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl;
                BlockTableRecord acBlkTblRec;

                // Abre o model space para escrever
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;

                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

                PromptAngleOptions angOpts = new PromptAngleOptions("\nSelecione o angulo...");
                angOpts.BasePoint = ptStart;
                PromptDoubleResult angRes = acDoc.Editor.GetAngle(angOpts);

                Line acline1 = new Line(ptStart, ptEnd);
                acline1.Layer = "CT4";
                Line acline2 = new Line(ptStart, ptEnd);
                acline2.Layer = "TR2";
                Line acline3 = new Line(ptStart, ptEnd);
                acline3.Layer = "CT4";
                acline2.StartPoint = new Point3d(acline2.StartPoint.X , acline2.StartPoint.Y - 44.7, 0);
                acline2.EndPoint = new Point3d(acline2.EndPoint.X , acline2.EndPoint.Y - 44.7, 0);
                acline3.StartPoint = new Point3d(acline3.StartPoint.X , acline3.StartPoint.Y - 51, 0);
                acline3.EndPoint = new Point3d(acline3.EndPoint.X , acline3.EndPoint.Y - 51, 0);



                acline1.SetDatabaseDefaults();
                acline2.SetDatabaseDefaults();
                acline3.SetDatabaseDefaults();
                // Adicionar as linhas ao desenho
                acBlkTblRec.AppendEntity(acline1);
                acBlkTblRec.AppendEntity(acline2);
                acBlkTblRec.AppendEntity(acline3);
                acTrans.AddNewlyCreatedDBObject(acline1, true);
                acTrans.AddNewlyCreatedDBObject(acline2, true);
                acTrans.AddNewlyCreatedDBObject(acline3, true);
                // Confirma as alterações
                acTrans.Commit();
            }
        }
    }
}

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Draw Multi-line without jig?
« Reply #8 on: October 22, 2010, 03:22:58 PM »
It looks like you get the angle and do nothing with it.   angRes

josano

  • Guest
Re: Draw Multi-line without jig?
« Reply #9 on: October 22, 2010, 03:58:37 PM »
Jeff,

How do I add the angled lines?
I'm trying but I can not understand how to change the angle with the remaining values.

Hugs,
Josano

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Draw Multi-line without jig?
« Reply #10 on: October 22, 2010, 04:18:52 PM »
Thanks for the hug,
GetAngle I think will vary depending on "AUNITS" setting. All you getting is back is a double

Would you rather just let them pick a point a 3rd point like drawing a regular line but with the other 2 lines generated?


josano

  • Guest
Re: Draw Multi-line without jig?
« Reply #11 on: October 22, 2010, 04:25:34 PM »
Jeff,

I thought about how to generate all but dont know not yet know how to work well.
Then the form that was able to generate the other two lines.
I thank you for your help. :)
I'm going crazy from trying to insert correctly.

Hugs,
Josano

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Draw Multi-line without jig?
« Reply #12 on: October 22, 2010, 05:13:39 PM »
When I get a minute I will post something that might help.

In the meantime you can look at the developer's guide under these headings for ideas

Calculate Points and Values
Offset Objects
Transform Objects
Move Objects

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Draw Multi-line without jig?
« Reply #13 on: October 26, 2010, 09:32:49 AM »
You might also consider using polylines
Here is offsetting some lines but there probably is a better way.
Code: [Select]
[CommandMethod("MulltiLineOffSet")]
        public void MulltiLineOffSet()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            Point3d startPnt;
            Point3d endPnt;
            PromptPointOptions ppo = new PromptPointOptions("\nSelect Point: ");
            PromptPointResult ppr;
           
            using (Transaction trx = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btrMs = SymbolUtilityServices.GetBlockModelSpaceId(db).GetObject(OpenMode.ForWrite) as BlockTableRecord;
                ppr = ed.GetPoint(ppo);
                if (ppr.Status != PromptStatus.OK)
                {
                    return;
                }
                startPnt = ppr.Value;
                do
                {             
                    ppo.UseBasePoint = true;
                    ppo.BasePoint = startPnt;
                    ppo.UseDashedLine = true;
                    ppr = ed.GetPoint(ppo);
                    if (ppr.Status != PromptStatus.OK)
                    {
                        break;
                    }
                    endPnt = ppr.Value;
                    Line lne = new Line(startPnt, endPnt);                 
                    btrMs.AppendEntity(lne);
                    trx.AddNewlyCreatedDBObject(lne, true);
                    foreach (Entity ent in lne.GetOffsetCurves(-44.7))
                    {
                        btrMs.AppendEntity(ent);
                        trx.AddNewlyCreatedDBObject(ent, true);
                    }
                    foreach (Entity ent in lne.GetOffsetCurves(-51))
                    {
                        btrMs.AppendEntity(ent);
                        trx.AddNewlyCreatedDBObject(ent, true);
                    }

                    db.TransactionManager.QueueForGraphicsFlush();
                    startPnt = endPnt;
                }
                while (ppr.Status == PromptStatus.OK);               
                trx.Commit();
            }
                     

        }

The pic shows lines on the left offset and polyline on the right offset

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Draw Multi-line without jig?
« Reply #14 on: October 26, 2010, 09:55:12 AM »
Here is code copied from Kean Walmsley @ Through-The-Interface

And just added the last little bit for offset



Code: [Select]
      [CommandMethod("MYPOLY")]

        public void MyPoly()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            Color col = doc.Database.Cecolor;
            Point3dCollection pts = new Point3dCollection();   
       
            PromptPointOptions opt = new PromptPointOptions("\nSelect polyline vertex: " );
            opt.AllowNone = true;

            PromptPointResult res = ed.GetPoint(opt);

            while (res.Status == PromptStatus.OK)
            {
                pts.Add(res.Value);


                opt.UseBasePoint = true;

                opt.BasePoint = res.Value;

                res = ed.GetPoint(opt);

                if (res.Status == PromptStatus.OK)
                {
                    ed.DrawVector( pts[pts.Count - 1], res.Value, col.ColorIndex,false);   
                }

            }

            if (res.Status == PromptStatus.None)
            {         

                Matrix3d ucs =  ed.CurrentUserCoordinateSystem;
                Point3d origin = new Point3d(0, 0, 0);
                Vector3d normal = new Vector3d(0, 0, 1);
                normal = normal.TransformBy(ucs);

                Plane plane = new Plane(origin, normal);
                Polyline pline = new Polyline(pts.Count);
                pline.Normal = normal;
                foreach (Point3d pt in pts)
                {
                    Point3d transformedPt = pt.TransformBy(ucs);

                    pline.AddVertexAt(pline.NumberOfVertices, plane.ParameterOf(transformedPt), 0, 0, 0);

                }

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {

                    BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                    BlockTableRecord btr =(BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                    ObjectId plineId = btr.AppendEntity(pline);

                    tr.AddNewlyCreatedDBObject(pline, true);
                    foreach (Entity ent in pline.GetOffsetCurves(-44.7))
                    {
                        btr.AppendEntity(ent);
                        tr.AddNewlyCreatedDBObject(ent, true);
                    }
                    foreach (Entity ent in pline.GetOffsetCurves(-51))
                    {
                        btr.AppendEntity(ent);
                        tr.AddNewlyCreatedDBObject(ent, true);
                    }

                    tr.Commit();

                }
            }
        }

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Draw Multi-line without jig?
« Reply #15 on: October 26, 2010, 10:56:55 AM »
Using vectors,  the line is easy, so have a go at adding that
Code: [Select]
        [CommandMethod("MultiLine")]
        public void MultiLine()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = HostApplicationServices.WorkingDatabase;
            Matrix3d ucs = ed.CurrentUserCoordinateSystem;
            CoordinateSystem3d Cs = ucs.CoordinateSystem3d;
            Plane pn = new Plane(Point3d.Origin, Cs.Zaxis);
            Vector3d normal = Cs.Zaxis;
            //First point
            PromptPointResult Pres = ed.GetPoint("\nPick the first point:");
            if (Pres.Status != PromptStatus.OK) return;
            Point3d U1 = Pres.Value;

            //Second point
            PromptPointOptions PPO = new PromptPointOptions
                ("\nPick the second point:");
            PPO.UseBasePoint = true;
            PPO.BasePoint = U1;
            Pres = ed.GetPoint(PPO);

            if (Pres.Status != PromptStatus.OK) return;

            Point3d U2 = Pres.Value;
            if (U1.Z != U2.Z) U2 = new Point3d(U2.X, U2.Y, U1.Z);

            //Add pline
            Polyline oPline = new Polyline(7);
            oPline.Normal = Cs.Zaxis;
            oPline.Elevation = -new Plane(Cs.Origin, Cs.Zaxis).Coefficients.D;
            if (U1.Z != 0) oPline.Elevation = oPline.Elevation + U1.Z;

            Point2d P1 = U1.TransformBy(ucs).Convert2d(pn);
            Point2d P2 = U2.TransformBy(ucs).Convert2d(pn);
            oPline.AddVertexAt(0, P1, 0, 0, 0);
            oPline.AddVertexAt(1, P2, 0, 0, 0);
            Vector2d v = (P2 - P1).GetNormal().RotateBy(Math.PI * 0.5);

            using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
            {
                BlockTableRecord Cspace = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                Cspace.AppendEntity(oPline);
                tr.AddNewlyCreatedDBObject(oPline, true);
                tr.Commit();
            }
            Double dOffset = 51;

            //Always on the bottom
            int iOffset = 1;
            if (P2.X < P1.X) iOffset = -1;

            v = v * iOffset * -dOffset;
            using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
            {
                oPline = tr.GetObject(oPline.Id, OpenMode.ForWrite) as Polyline;
                oPline.AddVertexAt(2, P2.Add(v), 0, 0, 0);
                oPline.AddVertexAt(3, P1.Add(v), 0, 0, 0);
                oPline.Closed = true;
                tr.Commit();
            }


        } //End MultiLine

josano

  • Guest
Re: Draw Multi-line without jig?
« Reply #16 on: October 26, 2010, 02:28:31 PM »
Jeff, Bryco and friends,

Thank you all for your support.
I think now I can develop the part of beam.
Please excuse me for the work, but I'm still crawling in autocad.net, with everyone's help understand more about lines, polylines and offset.

Hugs,
Josano