25 Ocak 2017 Çarşamba

Microstation VBA Element ekleme

Sub YaziYaz()
Dim ele As Element
Dim nokta As Point3d
nokta.x = 0
nokta.y = 0
Set ele = besuYazi("Deneme", "sil", nokta, 0, 3, 2, 2, 8, True)
Set ele = besuNokta(nokta, "nokta", 3, 1, True)
End Sub

Function besuYazi(yazi As String, lev As String, origin As Point3d, aci As Double, renk As Integer, yuk As Double, gen As Double, jst As Integer, ekle As Boolean) As Element
    Dim tAci As Matrix3d
    tAci = Matrix3dFromAxisAndRotationAngle(2, aci)
    Dim j As Integer
    Set besuYazi = CreateTextElement1(Nothing, yazi, origin, tAci)
    besuYazi.level = besuLevel(lev)
    besuYazi.AsTextElement.TextStyle.Height = yuk
    besuYazi.AsTextElement.TextStyle.Width = gen
    besuYazi.Color = renk
    besuYazi.LineStyle = ByLevelLineStyle
    besuYazi.LineWeight = ByLevelLineWeight
   
    Set oFont = ActiveDesignFile.Fonts.Find(msdFontTypeWindowsTrueType, "Arial")
    Set besuYazi.AsTextElement.TextStyle.Font = oFont
   
    ' oNewElement.Color = 5
    besuYazi.AsTextElement.TextStyle.Justification = jst
    If ekle Then
       ActiveModelReference.AddElement besuYazi
    End If
    besuYazi.Redraw
End Function

Function besuNokta(origin As Point3d, lev As String, renk As Integer, kln As Integer, ekle As Boolean) As Element
    Set besuNokta = CreateLineElement2(Nothing, origin, origin)
    besuNokta.level = besuLevel(lev)
    besuNokta.Color = renk
    besuNokta.LineWeight = kln
    If ekle Then
       ActiveModelReference.AddElement besuNokta
    End If
    besuNokta.Redraw
End Function


Function besuLevel(levname As String) As level
   Set besuLevel = ActiveDesignFile.Levels.Find(levname)
   If besuLevel Is Nothing Then
      CadInputQueue.SendKeyin "level create " & Chr(34) & levname & Chr(34)
      Set besuLevel = ActiveDesignFile.Levels.Find(levname)
   End If
End Function


Hiç yorum yok:

Yorum Gönder