How to Explode a line?

How to Explode a line?

Anonymous
Not applicable
9,381 Views
5 Replies
Message 1 of 6

How to Explode a line?

Anonymous
Not applicable

hi,everyone:

suppose i have drawed a line, and i 'd like to divide it into 3 lines,

maybe i can use a point right on the line to decide where to cut this

line, could anyone help me? thanks

0 Likes
Accepted solutions (1)
9,382 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

perhaps try the DIVIDE or MEASURE commands.

 

Regards,

0 Likes
Message 3 of 6

Anonymous
Not applicable

Sir, thanks for answering my question. but i want my program to do this automatic, not by users,can you help me?

0 Likes
Message 4 of 6

Anonymous
Not applicable

The way I would normally achieve this is to delete the original line, and draw smaller lines of your own instead.

 

I have created a brief tutorial for how to achieve this at the link below:

 

http://howtoautocad.com/break-a-line-into-smaller-pieces-using-vba-or-vb-net-in-autocad/

 

Regards,

0 Likes
Message 5 of 6

Anonymous
Not applicable
Accepted solution

Remember that a line is simply a Curve at its base. Thus you can use the Curve.GetSplitCurves method which will return a collection of DBObjects that you can append to the space. Hope this points you in the right direction. If you need more help, let us know.

 

Using lck As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument
            Using db As Database = HostApplicationServices.WorkingDatabase
                Using trans As Transaction = db.TransactionManager.StartTransaction
                    Try
                        Dim cur As Curve = trans.GetObject(prEnt.ObjectId, OpenMode.ForWrite)
                        Dim pt3Dcol As New Point3dCollection
                        Dim endDist As Double = cur.GetDistAtPoint(cur.EndPoint)
                        Dim divLen As Double = endDist / 3.0
                        Dim pt As Point3d

                        For dbl As Double = 0.0 To endDist Step divLen
                            pt = cur.GetPointAtDist(dbl)
                            pt3Dcol.Add(pt)
                        Next

                        If pt3Dcol.Count = 0 Then GoTo TransEnd

                        Dim objCOl As DBObjectCollection = cur.GetSplitCurves(pt3Dcol)

                        Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead, False)
                        Dim btr As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)

                        If objCOl.Count > 0 Then
                            For Each dbObj As DBObject In objCOl
                                btr.AppendEntity(dbObj)
                                trans.AddNewlyCreatedDBObject(dbObj, True)
                            Next
                        End If

                        cur.Erase()

TransEnd:
                        trans.Commit()
                    Catch
                        trans.Abort()
                    End Try
                End Using
            End Using
        End Using

 

 

 

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

Hello,

 

I've spent some time away from AutoCAD .net while working within Revit .net  and was curious when did everything begin to derive from Curve?  That is exactly what Revit's model structure does.  Starting to think that one day there will be a single CAD software that does it all $,$$$,$$$.$$.

 

jvj

0 Likes