Author Topic: Some basic dimensions function  (Read 1291 times)

0 Members and 1 Guest are viewing this topic.

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Some basic dimensions function
« on: May 01, 2012, 07:49:36 AM »
Code: [Select]
        Public Sub DrawRotDimension(ByVal db As Database, ByVal tr As Transaction, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal offset As Double, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return
            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
            Dim ang As Double = AngleFromXAxis(pt1, pt2)
            Dim pt3 As Point3d = PolarPoint(pt2, ang + Math.PI / 2, offset)
            Dim odim As RotatedDimension = New RotatedDimension(ang, pt1, pt2, pt3, "<>", dtr.ObjectId)
            odim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(odim)
            tr.AddNewlyCreatedDBObject(odim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawAlignDimension(ByVal db As Database, ByVal tr As Transaction, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal pt3 As Point3d, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return

            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
            Dim odim As AlignedDimension = New AlignedDimension(pt1, pt2, pt3, "", dtr.ObjectId)
            odim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(odim)
            tr.AddNewlyCreatedDBObject(odim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawLineAngDimension(ByVal db As Database, ByVal tr As Transaction, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal pt3 As Point3d, ByVal pt4 As Point3d, ByVal pt5 As Point3d, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return

            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
            Dim adim As LineAngularDimension2 = New LineAngularDimension2(pt1, pt2, pt3, pt4, pt5, "", dtr.ObjectId)

            adim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(adim)
            tr.AddNewlyCreatedDBObject(adim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawOrdinateDimension(ByVal db As Database, ByVal tr As Transaction, isAxis As Boolean, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return
            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)

            Dim strdim As String = String.Format("{0:f3}\P{1:f3}", pt1.X, pt1.Y)
            Dim adim As OrdinateDimension = New OrdinateDimension(isAxis, pt1, pt2, strdim, dtr.ObjectId)

            adim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(adim)
            tr.AddNewlyCreatedDBObject(adim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawArcDimension(ByVal db As Database, ByVal tr As Transaction, ByVal cpt As Point3d, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal pt3 As Point3d, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return

            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)

            Dim adim As ArcDimension = New ArcDimension(cpt, pt1, pt2, pt3, "", dtr.ObjectId)
            adim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(adim)
            tr.AddNewlyCreatedDBObject(adim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawDiametricDimension(ByVal db As Database, ByVal tr As Transaction, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal leg As Double, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return

            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
            Dim odim As DiametricDimension = New DiametricDimension(pt1, pt2, leg, "", dtr.ObjectId)
            odim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(odim)
            tr.AddNewlyCreatedDBObject(odim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawRadialDimension(ByVal db As Database, ByVal tr As Transaction, ByVal cpt As Point3d, ByVal pt1 As Point3d, ByVal leg As Double, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return

            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
            Dim odim As RadialDimension = New RadialDimension(cpt, pt1, leg, "", dtr.ObjectId)

            odim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(odim)
            tr.AddNewlyCreatedDBObject(odim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawRadialDimensionLarge(ByVal db As Database, ByVal tr As Transaction, ByVal cpt As Point3d, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal pt3 As Point3d, ByVal ang As Double, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return

            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
            Dim odim As RadialDimensionLarge = New RadialDimensionLarge(cpt, pt1, pt2, pt3, ang, "", dtr.ObjectId)

            odim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(odim)
            tr.AddNewlyCreatedDBObject(odim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub

        Public Sub DrawPoint3AngularDimension(ByVal db As Database, ByVal tr As Transaction, ByVal cpt As Point3d, ByVal pt1 As Point3d, ByVal pt2 As Point3d, ByVal pt3 As Point3d, ByVal dimStyleName As String)

            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            Dim dtb As DimStyleTable = CType(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
            If Not dtb.Has(dimStyleName) Then Return

            Dim dtr As DimStyleTableRecord = CType(tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
            Dim odim As Point3AngularDimension = New Point3AngularDimension(cpt, pt1, pt2, pt3, "", dtr.ObjectId)

            odim.SetDatabaseDefaults()
            ''change some properties of the dimension if it is needs here
            ''..........................................
            btr.AppendEntity(odim)
            tr.AddNewlyCreatedDBObject(odim, True)
            ' commit transaction or do it in the main program
            ' tr.Commit()
        End Sub


        '' published by Irvin on May 12, 2009 1:25 PM
        '' http://forums.autodesk.com/t5/NET/Set-current-textstyle/m-p/2485015/highlight/true#M14423
        '' (slightly edited)
        <CommandMethod("SetDimStlye")> _     
        Public Sub SetDimStyle(ByVal dimStyleName As String)
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            Using trans As Transaction = db.TransactionManager.StartTransaction()
                Dim DimTbl As DimStyleTable = CType(trans.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
                If DimTbl.Has(dimStyleName) Then
                    Dim DimRecord As DimStyleTableRecord = CType(trans.GetObject(DimTbl(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
                    If DimRecord.ObjectId <> db.Dimstyle Then
                        db.Dimstyle = DimRecord.ObjectId
                        db.SetDimstyleData(DimRecord)
                    End If
                End If
                trans.Commit()
            End Using
            Dim dimstyleStr As String = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("dimstyle").ToString()
            ed.WriteMessage(vbCr & "Current Dimstyle now: {0}", dimstyleStr)
        End Sub

        <CommandMethod("GetDimStlye")> _
        Public Sub GetCurrDimStyle()
            Dim dimstyleStr As String = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("dimstyle").ToString()
            Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("First method: " & dimstyleStr)
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Dim db As Database = doc.Database
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim dt As DimStyleTable = DirectCast(tr.GetObject(db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
                Dim id As ObjectId = db.Dimstyle
                Dim dr As DimStyleTableRecord = DirectCast(tr.GetObject(id, OpenMode.ForRead), DimStyleTableRecord)
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Second method: " & dr.Name)
            End Using
        End Sub


        <CommandMethod("ChangeDimStlye")> _
        Public Sub ChangeDimStlye()

            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            Using tr As Transaction = db.TransactionManager.StartTransaction()

                Dim dimTbl As DimStyleTable = tr.GetObject(db.DimStyleTableId, OpenMode.ForRead)
                Dim dimDtr As DimStyleTableRecord = tr.GetObject(dimTbl("DimStyle1"), OpenMode.ForRead)
                Dim ids As ObjectIdCollection = dimDtr.GetPersistentReactorIds()
                For Each objId As ObjectId In ids

                    If objId.ObjectClass.IsDerivedFrom(RXClass.GetClass(GetType(Dimension))) Then

                        Dim dimen As Dimension = tr.GetObject(objId, OpenMode.ForWrite)
                        dimen.DimensionStyle = dimTbl("DimStyle2")
                        ''''' or
                        ''''''dimen.DimensionStyleName = "DimStyle2"
                    End If
                Next
                tr.Commit()
            End Using
        End Sub

        Public Shared Function GetPlineCoordinates(ByVal ent As Polyline) As Point3dCollection

            Dim pts As Point3dCollection = New Point3dCollection()
            Dim coord As Point3d
            Dim i As Integer = 0
            For i = 0 To ent.NumberOfVertices - 1
                coord = ent.GetPoint3dAt(i)
                pts.Add(coord)
            Next
            Return pts
        End Function

        Public Function Distance(ByVal fPoint As Point3d, ByVal sPoint As Point3d) As Double
            Dim x1, x2 As Double
            Dim y1, y2 As Double
            Dim z1, z2 As Double
            Dim cDist As Double
            x1 = fPoint.X : y1 = fPoint.Y : z1 = fPoint.Z
            x2 = sPoint.X : y2 = sPoint.Y : z2 = sPoint.Z
            cDist = Math.Sqrt(((x2 - x1) ^ 2) + ((y2 - y1) ^ 2))
            Return cDist
        End Function

        '' by Tony Tanzillo
        Public Function AngleFromXAxis(ByVal p1 As Point3d, ByVal p2 As Point3d) As Double

            Return New Vector2d(p2.X - p1.X, p2.Y - p1.Y).Angle

        End Function

        '' by Tony Tanzillo
        Public Function PolarPoint(ByVal basepoint As Point3d, ByVal angle As Double, ByVal distance As Double) As Point3d
            Return New Point3d( _
            basepoint.X + (distance * Math.Cos(angle)), _
            basepoint.Y + (distance * Math.Sin(angle)), _
            basepoint.Z)
        End Function

        Public Shared Function GetFirstPoint(ed As Editor, msg As String, ByRef pt As Point3d) As Boolean
            pt = New Point3d()

            Dim opt As New PromptPointOptions(vbLf & msg)

            Dim res As PromptPointResult = ed.GetPoint(opt)

            If res.Status = PromptStatus.OK Then
                pt = res.Value

                Return True
            Else
                Return False
            End If
        End Function
     
        Public Shared Function GetNextPoint(ed As Editor, msg As String, frompt As Point3d, ByRef pt As Point3d) As Boolean

            Dim opt As New PromptPointOptions(vbLf & msg)

            opt.UseBasePoint = True

            opt.AllowNone = True

            opt.BasePoint = frompt

            Dim res As PromptPointResult = ed.GetPoint(opt)

            If res.Status = PromptStatus.OK Then
                pt = res.Value
                Return True
            Else
                Return False
            End If
        End Function

Offline dockee

  • Newbie
  • *
  • Posts: 5
  • Karma: +1/-0
  • Gender: Male
    • prefered language: VB
    • Prog expertise: Good
    • View Profile
Re: Some basic dimensions function
« Reply #1 on: March 13, 2013, 10:33:40 PM »
hi,

I manage to create an aligneddim but I have one parameter to put this last in a grid iso autocad.

Can you help me.

Thanks.

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Re: Some basic dimensions function
« Reply #2 on: March 14, 2013, 03:50:40 PM »
Can you upload small picture (.png or .jpg) to see what
you exacrly need?

Offline dockee

  • Newbie
  • *
  • Posts: 5
  • Karma: +1/-0
  • Gender: Male
    • prefered language: VB
    • Prog expertise: Good
    • View Profile
Re: Some basic dimensions function
« Reply #3 on: March 15, 2013, 09:54:33 PM »
It's not necessary. I find solution. My calculaltion on angle is not right.

When i finalize my project, i Put a picture with the part of code.

Thanks.


Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Re: Some basic dimensions function
« Reply #4 on: March 16, 2013, 06:54:40 AM »
Ok, will be glad to see your final solution,
Kind regards,
Oleg

Offline dockee

  • Newbie
  • *
  • Posts: 5
  • Karma: +1/-0
  • Gender: Male
    • prefered language: VB
    • Prog expertise: Good
    • View Profile
Re: Some basic dimensions function
« Reply #5 on: May 13, 2013, 05:17:16 PM »
This is the solution to put an isométric dim as this picture.




Code: [Select]
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common


Public Class Main

' Programme de cotation isomètrique
' mai 2013 REV 1.0
' Auteur : F. LEGAY


#Region "programme principal"

<CommandMethod("COTISO")> _
Sub Main()

' Déclaration des variables
Dim OldLayer = Application.GetSystemVariable("clayer")
Dim OldOrtho = Application.GetSystemVariable("orthomode")
Dim OldSnap = Application.GetSystemVariable("snapmode")
Dim CotAng As Double
Dim plan As Integer = Application.GetSystemVariable("snapisopair")
Dim dimStyleName As String = "iso8-30"
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim Db As Database = HostApplicationServices.WorkingDatabase
Dim Ed As Editor = Doc.Editor

' Activation de la couche pour dessinner les cotations
Application.SetSystemVariable("clayer", "10 - COTATION")

' Demande le premier point
Dim Pt1 As New Point3d
Dim Opt1 As New PromptPointOptions(vbLf & "Entrer le premier point")
Dim Res1 As PromptPointResult = Ed.GetPoint(Opt1)

If Res1.Status = PromptStatus.OK Then
Pt1 = Res1.Value
End If

' Demande le deuxième point
Dim Pt2 As New Point3d
Dim Opt2 As New PromptPointOptions(vbLf & "Entrer le deuxième point")
Dim Res2 As PromptPointResult = Ed.GetPoint(Opt2)

If Res2.Status = PromptStatus.OK Then
Pt2 = Res2.Value
End If

Dim ang As Double = AngleFromXAxis(Pt1, Pt2)
Dim angdeg As String = CType((180 * ang / Math.PI), String)

' Demande la position de la ligne de cote
Dim Pt3 As New Point3d
Dim Opt3 As New PromptPointOptions(vbLf & "Entrer la position de la ligne de cote")
Dim Res3 As PromptPointResult = Ed.GetPoint(Opt3)

If Res3.Status = PromptStatus.OK Then
Pt3 = Res3.Value
End If

' Demande la position de la ligne de cote
Dim DimStr As String = ""
Dim StrOpt As New PromptStringOptions(vbLf & "Entrer la valeur de la cotation")
Dim ResStr As PromptResult = Ed.GetString(StrOpt)

If ResStr.Status = PromptStatus.OK Then
DimStr = ResStr.StringResult
End If

'Détermine le style de cotation en cours
Using Tr As Transaction = Db.TransactionManager.StartTransaction

Dim DimTbl As DimStyleTable = CType(Tr.GetObject(Db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
If DimTbl.Has(dimStyleName) Then
Dim DimRecord As DimStyleTableRecord = CType(Tr.GetObject(DimTbl(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)
If DimRecord.ObjectId <> Db.Dimstyle Then
Db.Dimstyle = DimRecord.ObjectId
Db.SetDimstyleData(DimRecord)
End If
End If
Tr.Commit()

End Using

' Définit l'angle et de style de cotation a utiliser
Select Case angdeg
Case "90"
Select Case plan
Case 0
dimStyleName = "iso830"
CotAng = CType((Math.PI * 240 / 180.0), Double)
Case 2
dimStyleName = "iso8-30"
CotAng = CType((Math.PI * 120 / 180.0), Double)
End Select
Case "270"
Select Case plan
Case 0
dimStyleName = "iso830"
CotAng = CType((Math.PI * 240 / 180.0), Double)
Case 2
dimStyleName = "iso8-30"
CotAng = CType((Math.PI * 120 / 180.0), Double)
End Select
Case "330"
Select Case plan
Case 0
dimStyleName = "iso8-30"
CotAng = CType((Math.PI * 120 / 180.0), Double)
Case 1
dimStyleName = "iso830"
CotAng = CType((Math.PI * 240 / 180.0), Double)
End Select
Case "150"
Select Case plan
Case 0
dimStyleName = "iso8-30"
CotAng = CType((Math.PI * 120 / 180.0), Double)
Case 1
dimStyleName = "iso830"
CotAng = CType((Math.PI * 240 / 180.0), Double)
End Select
Case "30"
Select Case plan
Case 1
dimStyleName = "iso8-30"
CotAng = CType((Math.PI * 120 / 180.0), Double)
Case 2
dimStyleName = "iso830"
CotAng = CType((Math.PI * 240 / 180.0), Double)
End Select
Case "210"
Select Case plan
Case 1
dimStyleName = "iso8-30"
CotAng = CType((Math.PI * 120 / 180.0), Double)
Case 2
dimStyleName = "iso830"
CotAng = CType((Math.PI * 240 / 180.0), Double)
End Select
End Select


' Création de la cotation
Using Tr As Transaction = Db.TransactionManager.StartTransaction

Dim btr As BlockTableRecord = CType(Tr.GetObject(Db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim dtb As DimStyleTable = CType(Tr.GetObject(Db.DimStyleTableId, OpenMode.ForRead), DimStyleTable)
If Not dtb.Has(dimStyleName) Then Return
Dim dtr As DimStyleTableRecord = CType(Tr.GetObject(dtb(dimStyleName), OpenMode.ForRead), DimStyleTableRecord)

Dim odim As AlignedDimension = New AlignedDimension(Pt1, Pt2, Pt3, DimStr, dtr.ObjectId)
odim.SetDatabaseDefaults()
odim.Oblique = CotAng
btr.AppendEntity(odim)
Tr.AddNewlyCreatedDBObject(odim, True)

Tr.Commit()

End Using

'Application.SetSystemVariable("snapstyl", 1)
Application.SetSystemVariable("clayer", OldLayer)



  End Sub


  Public Function AngleFromXAxis(ByVal p1 As Point3d, ByVal p2 As Point3d) As Double

    Return New Vector2d(p2.X - p1.X, p2.Y - p1.Y).Angle

  End Function


#End Region


End Class

Sorry if it too long that put my code.