Author Topic: Batch convert 3dSolids to Mass Elements  (Read 3660 times)

0 Members and 1 Guest are viewing this topic.

jbuzbee

  • Swamp Rat
  • Posts: 851
Batch convert 3dSolids to Mass Elements
« on: October 03, 2006, 10:08:46 AM »
I have a couple of old models that were built using 3dsolids and wanted to convert over to mass elements for easy editing.  The model will be rendered in VIZ so all the VIZ materials are layer based.  I penned this little routine to automate the MASSELEMENTCONVERT command and to retain the original layer of the object.  Tested on 2006.

Code: [Select]
(defun c:jbBatchMassConvert(/ *Error* ss num cnt layername jbThisDrawing)
  (vl-load-com)
  (setq jbThisDrawing(vla-get-activedocument(vlax-get-acad-object)))
  (defun *Error* (Msg)
     (cond((or (not Msg)(member Msg '("console break" "Function cancelled" "quit / exit abort"))))
     ((princ (strcat "\nError: " Msg))))(princ))
  (vla-StartUndoMark jbThisDrawing)
  (setq ss(ssget(list(cons 0 "3DSOLID"))))
  (if ss
    (progn
      (setq num(sslength ss)
            cnt 0)
         (while (< cnt num)
   (setq layername(vla-get-layer(vlax-ename->vla-object (ssname ss cnt))))
   (command ".MASSELEMENTCONVERT" (ssname ss cnt) "" "_y" "")
   (vla-put-layer(vlax-ename->vla-object (entlast)) layername)
   (setq cnt(1+ cnt)))
      ))
  (vla-endUndoMark jbThisDrawing)
  (princ))
James Buzbee
Windows 8