Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting user input into mline vertexlist in VBA.. 1

Status
Not open for further replies.

basepointdesignz

Programmer
Jul 23, 2002
566
GB
Hi everyone,

I'm trying to write an VBA program for work in which it will draw a cavity wall based on user input for width and depth. The multiline used is already set up but I need the program to convert the dimensions in to vertex list so it can draw it.

I have two textboxes for the user to enter the dimensions (ie: 5000mm wide by 5000mm), basically drawing a square using a 'cavity wall' multiline. I have coded for user input/selection for the base/starting point (ie: 0,0,0). then it makes a vertex list from the base point minus the depth (ie: @0,-5000,0) and then the width (ie: @5000,0,0) and finally the end point (ie: @0,5000,0) - so draws an incomplete square (without the top line)..

Does anyone know how I'd go about this? I'm racking what brains I've got and still haven't come up with a solution..

Please can someone help!

Thanks in advance..

Renegade..
 
Is this what you are trying to do?

Sub DrawMultiLineBox()
Dim dWidth As Double
Dim dHeight As Double
Dim dPoint(14) As Double
Dim acMline As AcadMLine

dWidth = 5000#
dHeight = 5000#

dPoint(0) = 0#: dPoint(1) = 0#: dPoint(2) = 0#
dPoint(3) = dWidth: dPoint(4) = 0#: dPoint(5) = 0#
dPoint(6) = dWidth: dPoint(7) = dHeight: dPoint(8) = 0#
dPoint(9) = 0#: dPoint(10) = dHeight: dPoint(11) = 0#
dPoint(12) = 0#: dPoint(13) = 0#: dPoint(14) = 0#


Set acMline = ThisDrawing.ModelSpace.AddMLine(dPoint)

End Sub

BU
 
Thanks borgunit,

Yeah, that's basically what I'm trying to do. The only difference is that there would be these lines of code:

Code:
dwidth = textbox1.text
dheight = textbox2.text

...instead of:

Code:
dwidth = 5000#
dhwight = 5000#

...as the width and height is user input..


Thanks again mate. I will try it and let you know..


Also, how do you convert cylindrical and spherical coordinates into vertex points for a 3D polyline?

Cheers,

Renegade..

 
It is very similar to the mutiline example. This example is from the ACAD help file.

Sub Example_Add3DPoly()

Dim polyObj As Acad3DPolyline
Dim points(0 To 8) As Double

' Create the array of points
points(0) = 0: points(1) = 0: points(2) = 0
points(3) = 10: points(4) = 10: points(5) = 10
points(6) = 30: points(7) = 20: points(8) = 30

' Create a 3DPolyline in model space
Set polyObj = ThisDrawing.ModelSpace.Add3DPoly(points)
ZoomAll

End Sub


Bu
 
Thanks again Borgunit,

...but what I meant was how do I convert cylindrical/spherical coordinates - ie: @500<45,6 or @500<45<60. So I can convert the angular units into the vertex array to give an accurate point list.

I'm trying to write another program to draw a 3D helix. I have user input for all the dimensions of the coil. The program then calculates the vertex from the user input and draws it.

Once again thanks,

Renegade..
 
One other thing,

How do you go about coding for relative
coordinates in VBA. The code that you gave me for the multiline vertex list works excellently but they're all absolute coordinates and I need relative ones, as the user selects the starting point and the multiline draws from there.

Thanks again mate,

Renegade..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top