Proctor Posted March 18, 2010 Share Posted March 18, 2010 Hello: I'm working in AutoCad 2009 for .net api. If I draw a 2d polyline, I can use the LinetypeGenerationOn method for it to set the linetype generation = true; however, i don't know how to do this for when drawing a simple 1d polyline? (via my code). This method is not available for the simple polys. Here's code that works for the 2dpoly: _ PublicSharedSub drawPolyline() Dim myTransMan As DatabaseServices.TransactionManager Dim myTrans As DatabaseServices.Transaction Dim myDWG As Autodesk.AutoCAD.ApplicationServices.Document Dim myBT As DatabaseServices.BlockTable Dim myBTR As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord Try Dim myPoints AsNew Geometry.Point3dCollection myPoints.Add(New Geometry.Point3d(0, 0, 0)) myPoints.Add(New Geometry.Point3d(2, 2, 0)) myPoints.Add(New Geometry.Point3d(4, 0, 0)) myPoints.Add(New Geometry.Point3d(6, 2, 0)) myPoints.Add(New Geometry.Point3d(8, 0, 0)) 'Get the active document and begin a Transaction myDWG = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim docLock As DocumentLock = myDWG.LockDocument() myTransMan = myDWG.TransactionManager myTrans = myTransMan.StartTransaction myBT = myDWG.Database.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead) myBTR = myBT(BlockTableRecord.ModelSpace).GetObject(DatabaseServices.OpenMode.ForWrite) Dim myOneRowPoly AsNew DatabaseServices.Polyline2d(DatabaseServices.Poly2dType.SimplePoly, myPoints, 0, False, 0, 0, Nothing) myOneRowPoly.LinetypeGenerationOn = TruemyBTR.AppendEntity(myOneRowPoly) myTrans.AddNewlyCreatedDBObject(myOneRowPoly, True) myOneRowPoly.Visible = True myOneRowPolyLength = myOneRowPoly.Length myOneRowPolyNew = myOneRowPoly 'Commit the Transaction myTrans.Commit() myTrans.Dispose() Catch ex As Autodesk.AutoCAD.Runtime.Exception MsgBox(ex.Message) Finally 'trans.Dispose() EndTry EndSub Thank you, Proctor Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 18, 2010 Share Posted March 18, 2010 Proctor see here Quote Link to comment Share on other sites More sharing options...
Proctor Posted March 18, 2010 Author Share Posted March 18, 2010 sorry about that Lee Mac, let me try that again - previewing it, i see that doing it this way makes a big difference: <CommandMethod("dp")> _ PublicSharedSub drawPolyline() Dim myTransMan As DatabaseServices.TransactionManager Dim myTrans As DatabaseServices.Transaction Dim myDWG As Autodesk.AutoCAD.ApplicationServices.Document Dim myBT As DatabaseServices.BlockTable Dim myBTR As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord Try Dim myPoints AsNew Geometry.Point3dCollection myPoints.Add(New Geometry.Point3d(0, 0, 0)) myPoints.Add(New Geometry.Point3d(2, 2, 0)) myPoints.Add(New Geometry.Point3d(4, 0, 0)) myPoints.Add(New Geometry.Point3d(6, 2, 0)) myPoints.Add(New Geometry.Point3d(8, 0, 0)) 'Get the active document and begin a Transaction myDWG = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument Dim docLock As DocumentLock = myDWG.LockDocument() myTransMan = myDWG.TransactionManager myTrans = myTransMan.StartTransaction myBT = myDWG.Database.BlockTableId.GetObject(DatabaseServ ices.OpenMode.ForRead) myBTR = myBT(BlockTableRecord.ModelSpace).GetObject(Databa seServices.OpenMode.ForWrite) Dim myOneRowPoly AsNew DatabaseServices.Polyline2d(DatabaseServices.Poly2 dType.SimplePoly, myPoints, 0, False, 0, 0, Nothing) myOneRowPoly.LinetypeGenerationOn = TruemyBTR.AppendEntity(myOneRowPoly) myTrans.AddNewlyCreatedDBObject(myOneRowPoly, True) myOneRowPoly.Visible = True myOneRowPolyLength = myOneRowPoly.Length myOneRowPolyNew = myOneRowPoly 'Commit the Transaction myTrans.Commit() myTrans.Dispose() Catch ex As Autodesk.AutoCAD.Runtime.Exception MsgBox(ex.Message) Finally 'trans.Dispose() EndTry EndSub author: Jerry Winters Quote Link to comment Share on other sites More sharing options...
Proctor Posted March 19, 2010 Author Share Posted March 19, 2010 I found out how to do it for simple polylines: myNewPolyLine.Plinegen = True Thanks, Proctor Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.