Results 1 to 4 of 4

Thread: Create a polyline

  1. #1
    100 Club
    Join Date
    2004-08
    Location
    Beaverton, Or.
    Posts
    132
    Login to Give a bone
    0

    Default Create a polyline

    How do you create a polyline with .net starting with a 3d point (user input)? I have found lots of examples of creating plines with hard coded points, but none that start with user input.

    Any help would be great.
    Last edited by clintonc; 2010-11-11 at 07:00 PM.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,733
    Login to Give a bone
    0

    Default Re: Create a polyline

    Quote Originally Posted by clintonc View Post
    How do you create a polyline with .net starting with a 3d point (user input)? I have found lots of examples of creating plines with hard coded points, but none that start with user input.

    Any help would be great.
    Store a series of points to variables (pt1, pt2, pt3, etc.) then build your polyline accordingly.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Create a polyline

    Quote Originally Posted by clintonc View Post
    How do you create a polyline with .net starting with a 3d point (user input)? I have found lots of examples of creating plines with hard coded points, but none that start with user input.

    Any help would be great.
    Here is very easy example not so elegance though
    Code:
    Imports System
    Imports Autodesk.AutoCAD.Runtime
    Imports Autodesk.AutoCAD.Geometry
    Imports Autodesk.AutoCAD.EditorInput
    Imports Autodesk.AutoCAD.DatabaseServices
    Imports Autodesk.AutoCAD.GraphicsInterface
    Imports Autodesk.AutoCAD.ApplicationServices.Application
    Imports AcadRT = Autodesk.AutoCAD.Runtime
    Imports AcadED = Autodesk.AutoCAD.EditorInput
    Imports AcadDB = Autodesk.AutoCAD.DatabaseServices
    Imports AcadApp = Autodesk.AutoCAD.ApplicationServices.Application
     
    Public Class PlineUtils
        <CommandMethod("TP")> _
        Public Sub InteractPline()
            Dim adoc As Autodesk.AutoCAD.ApplicationServices.Document = AcadApp.DocumentManager.MdiActiveDocument
            Dim db As Database = adoc.Database
            Dim ed As Editor = adoc.Editor
     
            Dim vec As Vector3d = New Vector3d(0, 0, 1).TransformBy(ed.CurrentUserCoordinateSystem)
            Dim plane As Plane = New Plane(db.Ucsorg, vec)
            Dim res1 As PromptPointResult = ed.GetPoint(ControlChars.CrLf & "Select first point: ")
     
            Dim bp As Point3d = New Point3d(res1.Value.X, res1.Value.Y, res1.Value.Z)
            Dim ar As ArrayList = New ArrayList
            ar.Add(bp.X)
            ar.Add(bp.Y)
            Dim res2 As PromptPointResult
            Dim n As Integer = 0
     
            Do
                Dim opt As PromptPointOptions = New PromptPointOptions(ControlChars.CrLf & "Select next point: ")
     
                opt.AppendKeywordsToMessage = True
                opt.UseBasePoint = True
                opt.BasePoint = bp
                opt.AllowArbitraryInput = True
                opt.SetMessageAndKeywords(ControlChars.CrLf & "Select next point: " & "Or Yes to Exit [Y/N]", "Yes No")
                res2 = ed.GetPoint(opt)
                bp = New Point3d(res2.Value.X, res2.Value.Y, res2.Value.Z)
                ar.Add(bp.X)
                ar.Add(bp.Y)
                n += 1
            Loop Until res2.Status = PromptStatus.Keyword
     
            Dim Pline As Polyline = New Polyline(n)
            For i As Integer = 0 To ar.Count - 1 Step 2
                Pline.AddVertexAt(0, New Point2d(ar(i), ar(i + 1)), 0.0, 0.0, 0.0)
            Next i
     
            Pline.Normal = vec
            Pline.RemoveVertexAt(0)
     
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
                btr.AppendEntity(Pline)
                tr.AddNewlyCreatedDBObject(Pline, True)
                tr.Commit()
            End Using
     
        End Sub
    Guess, you might want to search for Jig entity examples in AU docs
    as well

    ~'J'~

  4. #4
    100 Club
    Join Date
    2002-10
    Posts
    154
    Login to Give a bone
    0

    Default Re: Create a polyline

    AutoDesk has some examples of this and much more...
    http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html?url=WS1a9193826455f5ff2566ffd511ff6f8c7ca-4217.htm,topicNumber=d0e10700

Similar Threads

  1. create alignment from 3d polyline
    By wardorichie in forum AutoCAD Civil 3D - General
    Replies: 4
    Last Post: 2017-09-29, 09:06 AM
  2. Create Polyline Offset
    By khanhtruongcivil399200 in forum AutoLISP
    Replies: 1
    Last Post: 2014-10-16, 11:36 AM
  3. 2011: Create a polyline Section from surface?
    By scowsert in forum AutoCAD 3D (2007 and above)
    Replies: 1
    Last Post: 2011-09-02, 11:03 AM
  4. help corrirdor -> create subassembly from polyline
    By ociosidad in forum AutoCAD Civil 3D - Corridors
    Replies: 1
    Last Post: 2009-06-15, 03:25 PM
  5. Create 3d Polyline Step
    By td729 in forum AutoCAD Civil 3D - Surfaces
    Replies: 4
    Last Post: 2008-04-26, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •