1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Enum ConAutocad
acBlockReference = 7
acAlignmentMiddleCenter = 10
End Enum
Enum ColorAcad
acByBlock = 0
acYellow = 1
acGreen = 3
acCyan = 4
acBlue = 5
acMagenta = 6
acWhite = 7
End Enum
Sub test()
Dim InserCadre(1 To 5) As Double
Dim MyAutocad As Object
Set MyAutocad = CreateObject("Autocad.application")
MyAutocad.Visible = True
InserCadre(1) = 100 'Coin Bas gauche X
InserCadre(2) = 0 'Coin Bas gauche Y
InserCadre(3) = 150 'Coin Haut droite X
InserCadre(4) = 25 'Coin Haut droite Y
InserCadre(5) = 0
CrateCadre MyAutocad.Documents(0), InserCadre, acMagenta
Dim InsertEti(1 To 3) As Double
InsertEti(1) = 125
InsertEti(2) = 12.5
CreateEtiquette MyAutocad.Documents(0), "toto", InsertEti, acCyan, acAlignmentMiddleCenter, Taille:=20
End Sub
Public Function CreateEtiquette(MyDocumment, txt As String, XY1, Couleur As ColorAcad, Alignment, Optional Rotation = 0, Optional Taille = 3)
Set CreateEtiquette = MyDocumment.ModelSpace.AddText(txt, XY1,Taille)
CreateEtiquette.Alignment = Alignment
If Alignment <> 0 Then CreateEtiquette.TextAlignmentPoint = XY1
CreateEtiquette.Rotation = Rotation
CreateEtiquette.Color = Couleur
CreateEtiquette.Application.ZoomPrevious
CreateEtiquette.Application.ZoomAll
End Function
Public Function CrateCadre(My Documment, InsertPointCadre, Couleur As ColorAcad)
Dim points(0 To 14) As Double
points(0) = InsertPointCadre(1): points(1) = InsertPointCadre(2): points(2) = InsertPointCadre(5)
points(3) = InsertPointCadre(3): points(4) = InsertPointCadre(2): points(5) = InsertPointCadre(5)
points(6) = InsertPointCadre(3): points(7) = InsertPointCadre(4): points(8) = InsertPointCadre(5)
points(9) = InsertPointCadre(1): points(10) = InsertPointCadre(4): points(11) = InsertPointCadre(5)
points(12) = InsertPointCadre(1): points(13) = InsertPointCadre(2): points(14) = InsertPointCadre(5)
Set CrateCadre = MyDocumment.ModelSpace.AddPolyline(points)
CrateCadre.Color = Couleur
CrateCadre.Application.ZoomPrevious
CrateCadre.Application.ZoomAll
End Function |
Partager