+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    test_52
    Guest

    Default MLine command in VBA

    Registered forum members do not see this ad.

    I am hoping that someone can help me work this out. I can't find any info on it anywhere else. I am trying to write a VBA program to draw a mline. I need to be able to change the distance between the mlines. I can do this thru the autocad command line by either changing the scale of the standard style or creating a new style for the distance between the lines. I cannot figure out how to do this in VBA thou. I have written the macro that will draw the mline, which I have listed below, but can't change the settings. Can anyone help?

    Sub Ductwork()
    Dim Duct As AcadMLine
    Dim StPoint As Variant
    Dim EndPoint As Variant
    Dim Points(5) As Double
    Dim Count As Integer
    Dim EndCounter As Integer
    Dim DuctExp As Variant

    'get user entered points
    With ThisDrawing.Utility
    StPoint = .GetPoint(, "Enter start point: ")
    EndPoint = .GetPoint(, "Enter end point: ")
    End With

    'enter start point and end point into Points double
    For Count = 0 To 2
    Points(Count) = StPoint(Count)
    EndCounter = Count + 3
    Points(EndCounter) = EndPoint(Count)
    Next Count

    'create mline
    Set Duct = ThisDrawing.ModelSpace.AddMLine(Points)

    End Sub

    Thanks,
    Jason

  2. #2
    Forum Newbie
    Using
    AutoCAD 2004
    Join Date
    Jan 2007
    Posts
    1

    Default Mline scale problem

    I am suffering from the same trouble. I think Autodesk has forgotten this detail. But a deficient solution is that use "scaleentity" method and then shorten the length of Mline.
    I coud not find any solution for mine is that I need to find drawn Mline scale (distance between Mline)

    I woud be thankfull if anyone tell me any solve method in VBA

  3. #3
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    Registered forum members do not see this ad.

    Data of MLine Styles contains in ACAD_MLINESTYLE dictionary. Data of each lines contains in next DXF groups: 49 - distance from 'zero line', 62- color, 6 - linestyle. For more details see DXF refference. Now I haven't access to AutoCAD and don'n write to you example in VBA. Threrefore in this forum is one of my routines with MLine Style creation function in VisualLISP:

    Code:
    (defun asmi-mlStyleCreate(Quont / dxfLst topOrd Count mlDict)
      (setq dxfLst
       (list'(0 . "MLINESTYLE")'(102 . "{ACAD_REACTORS")'(102 . "}")
        '(100 . "AcDbMlineStyle")(cons 2(strcat(itoa Quont)"_PLINES"))
        '(70 . 0)'(3 . "")'(62 . 256)'(51 . 1.5708)'(52 . 1.5708)
         (cons 71 Quont))
           Count 0.0
           topOrd(-(/ Quont 2.0) 0.5)
        ); end setq
      (repeat Quont
        (setq dxfLst(append dxfLst
                (list(cons 49(- topOrd Count))
                     '(62 . 256) '(6 . "BYLAYER")))
          Count(1+ Count)
          );end setq
         ); end repeat
        (if
         (null
          (member
        (assoc 2 dxfLst)(dictsearch(namedobjdict)"ACAD_MLINESTYLE")))
        (progn
          (setq mlDict
             (cdr
               (assoc -1(dictsearch(namedobjdict)"ACAD_MLINESTYLE"))))
          (dictadd mlDict
               (cdr(assoc 2 dxfLst))(entmakex dxfLst))
          ); end progn
        ); end if
        (strcat(itoa Quont)"_PLINES")
        ); end of
    This creates MLine Stile with number of lines from 2 to 16 (argument 'Quont') and distance between 1.0. Any others arguments can be added. For exampe you can save this listing in *.lsp file, load it and type in command line:

    Code:
     (asmi-mlStyleCreate 7)
    It creates MLine Stile '7_PLINES'. In VBA it's also available

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts