PDA

View Full Version : MLine command in VBA



test_52
2nd May 2005, 05:07 pm
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

yavuzdel
7th Jan 2007, 12:28 am
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

ASMI
7th Jan 2007, 12:53 pm
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:


(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:


(asmi-mlStyleCreate 7)

It creates MLine Stile '7_PLINES'. In VBA it's also available :wink: