CAD Forums => Vertically Challenged => Architecturally Speaking => Topic started by: jbuzbee on October 03, 2006, 10:08:46 AM

Title: Batch convert 3dSolids to Mass Elements
Post by: jbuzbee 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)
  (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
      (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)