.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

trouble convert .net polyline to com lwpolyline

1 REPLY 1
Reply
Message 1 of 2
wang890
405 Views, 1 Reply

trouble convert .net polyline to com lwpolyline

i used .net selection and selected a few polylines in modelspace. but i need to convert it to acadobject lwpolyline or 2 whatever in order to feed it to civil 3d volume surface boundary but that's another story i am not quite there yet. just having trouble getting the polyline acadobject. there is one website showed up on google but company blocked it.

 

originally i just use the

 

ob = oAcadDB.ObjectIdToObject(prEntityRes.ObjectId.OldIdPtr)

then used the ctype lwpolyline but didn't work.

 

which worked for my other objects like points. guess i haven't tried polylines yet.

 

then i used this:

 

 Private Sub btnSelPoly_Click(sender As System.Object, e As System.EventArgs) Handles btnSelPoly.Click


        Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor

        Dim prSelectionOptions As PromptSelectionOptions = New PromptSelectionOptions
        Dim prSelectionRes As PromptSelectionResult = ed.GetSelection(prSelectionOptions)

        If prSelectionRes.Status = PromptStatus.Error Then
            Me.Show()
            Exit Sub
        Else

            Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim acCurDb As Database = acDoc.Database
            Using lock As DocumentLock = acDoc.LockDocument
                Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                    Dim acDocEd As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor

                    Dim acBlkTbl As BlockTable
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)

                    Dim obj As DBObject
                    If prSelectionRes.Value.Count <> 0 Then

                        lvwPolyline.Items.Clear()

                        For i As Integer = 0 To prSelectionRes.Value.Count - 1
                            obj = acTrans.GetObject(prSelectionRes.Value.Item(i).ObjectId, OpenMode.ForWrite)
                            If TypeOf obj Is Polyline Then

                                Dim oPolylineNet As Polyline = CType(obj, Polyline)
                                Dim oPolyline As AcadPolyline = oPolylineNet.AcadObject
                                Dim lvwItem As ListViewItem = lvwPolyline.Items.Add(oPolyline.ObjectID)
                                lvwItem.SubItems.Add(oPolyline.Layer)
                                lvwItem.Tag = oPolyline
                            End If
                        Next
                    End If


                    acTrans.Commit()
                End Using
            End Using
        End If
    End Sub

 and still something with the object type

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
1 REPLY 1
Message 2 of 2
wang890
in reply to: wang890

ah never mind. this worked fine. maybe i had a typo when typing acadlwpolyline into acadpolyine.

 

    

For i AsInteger = 0 To prSelectionRes.Value.Count - 1

                obj = oAeccDb.ObjectIdToObject(prSelectionRes.Value.Item(i).ObjectId.OldIdPtr)

               

Dim oPolyline AsAcadLWPolyline = CType(obj, AcadLWPolyline)

                MsgBox(oPolyline.Coordinate(0).ToString)

           

Next

 

 

Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost