Exporting each solid as a 3ds File

Exporting each solid as a 3ds File

ADSK2007
Enthusiast Enthusiast
259 Views
1 Reply
Message 1 of 2

Exporting each solid as a 3ds File

ADSK2007
Enthusiast
Enthusiast

Good Morning

 

I have a lisp code which will export all Solids inside a drawing to a DWG file (Every solid is exported into 1 dwg file). So if I have 300 Solids in a drawing, it will generate 300 dwgs for me. Each solid is saved with the original file coordinates which is 0,0,0. I should also mention that all solids are created under their own layer. I have 300 layers If I have 300 solids and so on

What I need is to export each solid as a 3ds format and the file name correspond with the layer name (Solid 1 has its layer 3d01 so the 3ds file should also be named 3d01.3ds). Could someone please help me modify below code? I don't know much about coding and appreciate any help I could get here. Please see below

 

 

 

(vl-load-com)
(defun c:WBP ( / c_doc o_arr ss o_lst cnt fname)
    (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
          o_arr (vlax-make-safearray vlax-vbobject '(0 . 0))
          ss (ssget "_X" '((0 . "*SOLID") ))
    );end_setq

    (repeat (setq cnt (sslength ss))
      (setq o_lst (cons (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))) o_lst))
    );end_repeat
    
    (setq cnt 0)
    
    (foreach obj o_lst
      (setq sso (vla-add (vla-get-selectionsets c_doc) "PLO")
            fname (strcat (getvar 'dwgprefix) (itoa cnt) ".dwg")
      );end_setq
      (vlax-safearray-put-element o_arr 0 obj)
      (vla-additems sso o_arr)
      (vla-wblock c_doc fname sso)
      (vla-delete sso)
      (setq cnt (1+ cnt))
    );end_foreach  
);end_defun

 

 

 

Screenshot 2023-01-23 110419.jpg

Accepted solutions (1)
260 Views
1 Reply
Reply (1)
Message 2 of 2

hippe013
Advisor
Advisor
Accepted solution