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

Create 3dPolyLine

9 REPLIES 9
Reply
Message 1 of 10
gilseorin
486 Views, 9 Replies

Create 3dPolyLine

Hi, all.
I intend to do my code about 3dOffset.
First of all, creating 3dPolyLine is the big problem for me.
I couldn't find any example about creating 3dPolyLine.
Help me,plz.
Thanks in advance.
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: gilseorin

http://discussion.autodesk.com/thread.jspa?messageID=5315082
wrote in message news:5464486@discussion.autodesk.com...
Hi, all.
I intend to do my code about 3dOffset.
First of all, creating 3dPolyLine is the big problem for me.
I couldn't find any example about creating 3dPolyLine.
Help me,plz.
Thanks in advance.
Message 3 of 10
gilseorin
in reply to: gilseorin

Thank you,Paul.
Is it possible to get whole example code?
Thank you again.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Public Class GILSclass1
_
Public Sub Create3dPoly()

Dim pts As Point3dCollection = New Point3dCollection
Dim ptsArr As Double() = {0, 0, 0, 10, 10, 10, 0, 10, 10}
Dim i As Integer = 0
While i < ptsArr.Length
pts.Add(New Point3d(ptsArr(i), ptsArr(i + 1), ptsArr(i + 2)))
i = i + 3
End While
End Sub
End Class
Message 4 of 10
Anonymous
in reply to: gilseorin

What else do you need? Add the entity to the
database the same way you would for other
other entities. How do you add a line?
wrote in message news:5464633@discussion.autodesk.com...
Thank you,Paul.
Is it possible to get whole example code?
Thank you again.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Public Class GILSclass1
_
Public Sub Create3dPoly()

Dim pts As Point3dCollection = New Point3dCollection
Dim ptsArr As Double() = {0, 0, 0, 10, 10, 10, 0, 10, 10}
Dim i As Integer = 0
While i < ptsArr.Length
pts.Add(New Point3d(ptsArr(i), ptsArr(i + 1), ptsArr(i + 2)))
i = i + 3
End While
End Sub
End Class
Message 5 of 10
gilseorin
in reply to: gilseorin

Finally, I made the code.
But, Error occured.
How in the world,should I repair the following code?
It's too difficult to get correct code. Help me,plz.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry

Public Class GILSclass1
_
Public Sub Create3dPoly()
Dim pts As Point3dCollection = New Point3dCollection
Dim my3dpoly As Polyline3d = New Polyline3d(Poly3dType.SimplePoly, pts, False)
Dim ptsArr As Double() = {0, 0, 0, 10, 10, 10, 0, 10, 10}
Dim i As Integer = 0
While i < ptsArr.Length
pts.Add(New Point3d(ptsArr(i), ptsArr(i + 1), ptsArr(i + 2)))
i = i + 3
End While

Draw3dPoly(my3dPoly)
End Sub
Friend Function Draw3dPoly(ByVal my3dPoly As Polyline3d) As ObjectId
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim transMgr As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
Dim trans As Transaction = transMgr.StartTransaction
Try
Dim btr As BlockTableRecord = CType(trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
btr.AppendEntity(my3dPoly)
trans.AddNewlyCreatedDBObject(my3dPoly, True)
trans.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage("Error Message: " + ex.Message)
Finally
If Not (my3dPoly Is Nothing) Then
my3dPoly.Dispose()
End If
End Try
Return my3dPoly.ObjectId
End Function

End Class
Message 6 of 10
Anonymous
in reply to: gilseorin

In your main function you're adding your polyline before pts has any data.

In your draw function you're disposing of your object if its true and then
trying to get its ID...boom!

If my3dPloy = nothing is false then
Not m3dpoly = nothing is true...

wrote in message news:5465999@discussion.autodesk.com...
Finally, I made the code.
But, Error occured.
How in the world,should I repair the following code?
It's too difficult to get correct code. Help me,plz.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry

Public Class GILSclass1
_
Public Sub Create3dPoly()
Dim pts As Point3dCollection = New Point3dCollection
Dim my3dpoly As Polyline3d = New Polyline3d(Poly3dType.SimplePoly,
pts, False)
Dim ptsArr As Double() = {0, 0, 0, 10, 10, 10, 0, 10, 10}
Dim i As Integer = 0
While i < ptsArr.Length
pts.Add(New Point3d(ptsArr(i), ptsArr(i + 1), ptsArr(i + 2)))
i = i + 3
End While

Draw3dPoly(my3dPoly)
End Sub
Friend Function Draw3dPoly(ByVal my3dPoly As Polyline3d) As ObjectId
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor =
Application.DocumentManager.MdiActiveDocument.Editor
Dim transMgr As Autodesk.AutoCAD.DatabaseServices.TransactionManager
= db.TransactionManager
Dim trans As Transaction = transMgr.StartTransaction
Try
Dim btr As BlockTableRecord =
CType(trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite),
BlockTableRecord)
btr.AppendEntity(my3dPoly)
trans.AddNewlyCreatedDBObject(my3dPoly, True)
trans.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage("Error Message: " + ex.Message)
Finally
If Not (my3dPoly Is Nothing) Then
my3dPoly.Dispose()
End If
End Try
Return my3dPoly.ObjectId
End Function

End Class
Message 7 of 10
gilseorin
in reply to: gilseorin

Thank you for your reply.
Not yet,error occurs.
Plz,check my attached code and give me a piece of advice.
Message 8 of 10
Anonymous
in reply to: gilseorin

[code]
Public Sub Draw3DPoly()
Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Try
Dim bt As BlockTable = tr.GetObject(db.BlockTableId,
OpenMode.ForRead)
Dim btr As BlockTableRecord =
tr.GetObject(bt(BlockTableRecord.ModelSpace), _
OpenMode.ForWrite)
Dim pts As Point3dCollection = New Point3dCollection
Dim ptsArr As Double() = {0, 0, 0, 10, 10, 10, 0, 10, 10}
Dim i As Integer = 0
While i < ptsArr.Length
pts.Add(New Point3d(ptsArr(i), ptsArr(i + 1), ptsArr(i + 2)))
i = i + 3
End While
Dim my3dpoly As Polyline3d = New Polyline3d(Poly3dType.SimplePoly,
pts, False)
btr.AppendEntity(my3dpoly)
tr.AddNewlyCreatedDBObject(my3dpoly, True)
tr.Commit()
Catch
'...
Finally
tr.Dispose()
End Try
End Sub
[/code]
wrote in message news:5466362@discussion.autodesk.com...
Thank you for your reply.
Not yet,error occurs.
Plz,check my attached code and give me a piece of advice.
Message 9 of 10
gilseorin
in reply to: gilseorin

How happy I am! Pardon my ignorance.
Thank you so much.
I appreciate for your kindness and effort.
Message 10 of 10
Anonymous
in reply to: gilseorin

You're welcome. You may want to download the
labs here - save yourself some time.
http://usa.autodesk.com/adsk/servlet/index?id=1911627&siteID=123112


wrote in message news:5466387@discussion.autodesk.com...
How happy I am! Pardon my ignorance.
Thank you so much.
I appreciate for your kindness and effort.

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