Author Topic: Create meshes automatically  (Read 1822 times)

0 Members and 1 Guest are viewing this topic.

XeroPhane

  • Guest
Create meshes automatically
« on: May 16, 2006, 10:09:31 PM »
I've recently been toying with the drape function in AutoCAD (spec., ADT 2004).  The problem with drape is that it's neither solid nor mesh and so boolean functions don't quite work the way we might expect them to.  They do have an AEC method of boolean but it gets annoying when you have to function through AEC, only to find out that the drape didn't "fall" accurately in the first place.

So I've started to create the following routine:
Code: [Select]
(defun c:mesher ()
  (setq index 0)
  (setq group (ssget)); create group

  (setq gLim (sslength group))

  (princ "\nEnter number of columns: ")
  (setq width (getint))
  (princ "\nEnter number of rows: ")
  (setq height (getint))

  (command "_3dmesh" height width)
  (while (< index gLim)
    (setq Obj (entget (ssname group index)))
    (setq nPt (cdr (assoc 10 Obj)))
    (command nPt)
    (setq index (1+ index))
  )

  (setq group nil) ;close group
) ;end of mesher

With this routine, the idea is that the user selects a group of points already laid out and then the routine lays a mesh over the top of it.  From there, the user can convert the mesh to solid and go on their way with boolean operations.  I know, I know... there are a few problems with it so far.  The first being that it's only really effective in a rectilinear pattern, and that the user is first required to set up a system of points (this is where drape would ideally be handy because the user simply selects a group of lines and then performs the drape on them).  What I did to set up my experiment is first drew the lines then divided each line equally, thus giving me the points.  The main problem I'm fussing with is that AutoCAD arbitrarily selects the objects.  Meaning, there is no order to their selection so the mesh more resembles a web of a very confused spider.  I've tried placing the coordinate data into an array and then sorting it but LISP doesn't seem to think about these things the way I do.  My thought is to sort the array by somewhat average coordinates for each axis.

Does anyone have any insight into this?  Am I going about this all wrong?  Am I reinventing the wheel? :ugly:
« Last Edit: May 19, 2006, 01:59:39 PM by XeroPhane »