Sub DrawMLeader() ' Dim acadApp As AcadApplication Dim acadDoc As AcadDocument Application.DisplayAlerts = False ' ' On Error Resume Next Set acadApp = GetObject(, "AutoCAD.Application") On Error GoTo 0 ' , If acadApp Is Nothing Then Set acadApp = New AcadApplication acadApp.Visible = True End If ' On Error Resume Next Set acadDoc = acadApp.ActiveDocument On Error GoTo 0 ' - If acadDoc Is Nothing Then Set acadDoc = acadApp.Documents.Add acadApp.Visible = True End If Dim AML As AcadMLeader Dim xx As Long Dim ss As String ActiveCell.Cells.Activate ' ss = ActiveCell.Cells.Value ' Dim points(0 To 5) As Double ' Dim startPnt As Variant, endPnt As Variant Dim prompt1 As String, prompt2 As String prompt1 = vbCrLf & " : " prompt2 = vbCrLf & " : " startPnt = acadDoc.Utility.GetPoint(, prompt1) ' endPnt = acadDoc.Utility.GetPoint(startPnt, prompt2) ' ' MLeader points(0) = startPnt(0) points(1) = startPnt(1) points(2) = 0 points(3) = endPnt(0) points(4) = endPnt(1) points(5) = 0 Set AML = acadDoc.ModelSpace.AddMLeader(points, xx) ' AML.TextString = ss AML.ArrowheadType = acArrowNone ' - , Mleader AutoCAD AML.TextHeight = 250 AML.TextLeftAttachmentType = acAttachmentBottomOfTopLine AML.TextRightAttachmentType = acAttachmentBottomOfTopLine AML.LandingGap = 2 Dim entHandle As String entHandle = AML.Handle ' , , ActiveCell.Offset(0, 1).Value = entHandle acadDoc.Application.Update ' , , , . ActiveCell.Cells.Interior.ColorIndex = 6 End Sub
Dim blockObj As Object ' ' , - , : ' , -, Set blockObj = acadDoc.ModelSpace.InsertBlock(startPnt, " ", 1, 1, 1, 0, []) ' , -, , - ( ) Dim varAttributes As Variant varAttributes = blockObj.GetAttributes varAttributes(0).TextString = ss1 ' varAttributes(1).TextString = ss2 ' varAttributes(2).TextString = ss ' Dim entHandle As String ' , , Excel AutoCAD. entHandle = blockObj.Handle ActiveCell.Offset(0, 3).Value = entHandle
Source: https://habr.com/ru/post/261461/
All Articles