.NET

Reply
Active Contributor
bvyas89
Posts: 26
Registered: ‎01-16-2014
Message 11 of 15 (88 Views)

Re: Draw Tower WIth Dialog Box

02-20-2014 02:04 AM in reply to: mzakiralam

Thank you... With reference to your given code and modifications needed to draw tower my task is completed successfully. Thank you very much.

Active Contributor
bvyas89
Posts: 26
Registered: ‎01-16-2014
Message 12 of 15 (66 Views)

Re: Draw Tower WIth Dialog Box

03-11-2014 11:03 PM in reply to: bvyas89

Hello mr mzakiralam,

 

Can you please help me. I want to assign Dtext or label to each polyline while drawing it or after drawing it. how can i do that. I know how to assign dtext to line.. but confused with polyline. Please help me. Please  find the dwg attach herewith for reference.

 

code using to draw polyline is as below:

 

'get current document
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
'lock document as using modeless form
Using docLock As DocumentLock = doc.LockDocument
Using tx As Transaction = db.TransactionManager.StartTransaction()
'open blocktable
Dim bt As BlockTable = tx.GetObject(db.BlockTableId, OpenMode.ForRead)
'open model space for write
Dim ms As BlockTableRecord = tx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
'converte text value
Dim uWidth As Double = CDbl(TextBox1.Text)
Dim base As Double = CDbl(TextBox2.Text)
Dim tHeight As Double = CDbl(TextBox3.Text)
Dim Xx As Double = ((base - uWidth) / 2)
' Dim pt1 As Point2d = New Point2d(0, 0)
Dim pt1 As Point2d = New Point2d(0, 0)
Dim pt2 As Point2d = New Point2d(base, 0)
Dim pt3 As Point2d = New Point2d(base - Xx, tHeight)
Dim pt4 As Point2d = New Point2d(0, 0)
Dim pt5 As Point2d = New Point2d(0 + Xx, tHeight)
Dim pt6 As Point2d = New Point2d(base, 0)
'draw traiangle
Dim tra As Polyline = New Polyline()
tra.AddVertexAt(0, pt1, 0, 0, 0)
tra.AddVertexAt(1, pt2, 0, 0, 0)
tra.AddVertexAt(2, pt3, 0, 0, 0)
tra.AddVertexAt(3, pt4, 0, 0, 0)
tra.AddVertexAt(4, pt5, 0, 0, 0)
tra.AddVertexAt(5, pt6, 0, 0, 0)
tra.Closed = True
'add triangle in model space
ms.AppendEntity(tra)
tx.AddNewlyCreatedDBObject(tra, True)
Dim line1 As Line = New Line(New Point3d(pt5.X, pt5.Y, 0), New Point3d(pt3.X, pt3.Y, 0))
ms.AppendEntity(line1)
tx.AddNewlyCreatedDBObject(line1, True)
tx.Commit()
End Using
End Using

Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 13 of 15 (60 Views)

Re: Draw Tower WIth Dialog Box

03-12-2014 01:03 AM in reply to: bvyas89
Hi , I had a look into your drawing. But I did not get your requirement. Because that was a single poyline. How can I know that which Label shoul go where. if you make sure that for every vertex there will be a Label then it is easier. Please make clear your requirement. I recommend you to open a new thread for your Problem. As this thread has already been marked solved so other People will not look into your Problem.
Active Contributor
bvyas89
Posts: 26
Registered: ‎01-16-2014
Message 14 of 15 (57 Views)

Re: Draw Tower WIth Dialog Box

03-12-2014 02:04 AM in reply to: mzakiralam

thank you... I had already open a new tread but didnot get any solution from last 2 days so replied here. 

link to new thread is as below:

 

http://forums.autodesk.com/t5/NET/Assign-nomenclature-to-each-polyline/m-p/4874426

 

yes they are connecting polylines. with reference to your code i am able to draw  complete tower.

 

no i  want to label each line. within it.

Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 15 of 15 (53 Views)

Re: Draw Tower WIth Dialog Box

03-12-2014 02:39 AM in reply to: bvyas89

HI,

Okay, I got your point now. As you know how to draw text for a line so it will be easier for you now. What you need to do just cast the polyline then you will be able to get all vertices of that polyline. If you get all vertex then I think your problem will be solved. Please see below code snippet which will help you to get the polyline and its vertices.

 

 <CommandMethod("tst")> Public Sub TestPoly()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        Dim peo As PromptEntityOptions = New PromptEntityOptions(vbLf & "Select a polyline to label it:")
        Dim per As PromptEntityResult = ed.GetEntity(peo)
        Using tx As Transaction = db.TransactionManager.StartTransaction()
            Dim ent As Entity = tx.GetObject(per.ObjectId, OpenMode.ForRead)
            If TypeOf ent Is Polyline Then
                Dim pl As Polyline = TryCast(ent, Polyline)
                Dim vn As Integer = pl.NumberOfVertices
                For i = 0 To vn - 2
                    'get adjacent vertices of a polyline
                    Dim pt1 As Point2d = pl.GetPoint2dAt(i)
                    Dim pt2 As Point2d = pl.GetPoint2dAt(i + 1)
                    'do what you need
                Next
            End If
            tx.Commit()
        End Using
    End Sub

 

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.