VBA 3DMesh

Discussion in 'AutoCAD' started by Pienpeas, Jul 22, 2004.

  1. Pienpeas

    Pienpeas Guest

    Hi all,

    I want to create a 3DMesh with M = 100 and N = 50. I dont need any Z values to start with, i'll add them later. I want to start at 0,0. I figured its worth sorting a vba routine rather being sat there typing in 0,1 0,2 0,3.......

    Can anyone point me in the right direction?

    Much appreciated.
     
    Pienpeas, Jul 22, 2004
    #1
  2. Hi,

    For M = 1 to 100
    For N = 1 to 50
    Debug.Print cstr(M) & "," & cstr(N)
    Do anything else you like here
    Next N
    Next M

    Laurie Comerford
    CADApps
    www.cadapps.com.au

    values to start with, i'll add them later. I want to start at 0,0. I figured
    its worth sorting a vba routine rather being sat there typing in 0,1 0,2
    0,3.......
     
    Laurie Comerford, Jul 22, 2004
    #2
  3. Here's the example from the help file, modified to have variable # of faces.
    On my machine it gives overflow errors if I set both M and N to about 110 --
    I think it's because of the memory required for the a large points()
    array....

    HTH,
    James

    Option Explicit

    Sub Example_Add3DMesh_modified()
    ' This example creates a M X N polygonmesh in model space.
    Dim meshObj As AcadPolygonMesh
    Dim mSize As Integer, nSize As Integer
    Dim points() As Double
    Dim m As Integer, n As Integer

    mSize = 100
    nSize = 50
    ReDim points(0 To 3 * mSize * nSize - 1)

    For m = 1 To mSize
    For n = 1 To nSize
    points(3 * ((m - 1) * nSize + n) - 3) = m - 1 'x
    points(3 * ((m - 1) * nSize + n) - 2) = n - 1 'y
    points(3 * ((m - 1) * nSize + n) - 1) = 0 'z
    Next 'n
    Next 'm

    ' creates a 3Dmesh in model space
    Set meshObj = ThisDrawing.ModelSpace.Add3DMesh(mSize, nSize, points)

    End Sub
     
    James Belshan, Jul 23, 2004
    #3
  4. Pienpeas

    Pienpeas Guest

    Thanks Laurie & James.

    Yep, i got the same results as you James. However the 100:50 that i was wanting works fine & dandy.

    :)
     
    Pienpeas, Jul 23, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.