RE: Can AutoCAD 2000 generate STL file?

From: Kwok Kai Thong, Mariner (kaithong@TP.EDU.SG)
Date: Thu Jul 06 2000 - 04:02:50 EEST


interesting though, I have never tried it with AutoCad 2000, but did several
of this with Mechanical desktop 2 & 3. what I did was simply output it as
IGES file, input into SolidView and that it, I get the STL. But of course,
there is the problem of trimmed surface entities not supported. Wonder
whether they have fix it in MDT 4.

Mariner Kwok
Temasek Polytechnic
Temasek Engineering School
Singapore
tel: 7805562
  

-----Original Message-----
From: SCat3D@aol.com [mailto:SCat3D@aol.com]
Sent: Thursday, July 06, 2000 2:06 AM
To: rp-ml@bart.lpt.fi
Cc: wang-jiwen@usa.net
Subject: Re: Can AutoCAD 2000 generate STL file?

AutoCAD only outputs STL from a ACIS solid. But with the following LISP
routine I whipped up, any 3DFACE object will be written to an STL.
Notes:
You may need to run a repair program like Deskartes to weld gaps etc. before

building.
Before an Autosurf surface or IGES surface from another CAD program can be
written to STL, set your IGES input parameters to read in as facets instead
of surfaces.
Before a triangle mesh can be written to STL (such as the previously
mentioned IGES file or 3D Studio files for example) explode the objects
until
the all list as 3DFACES.

START OF LISP ROUTINE:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
(defun C:3dStlout()
;use the command "3dstlout" after loading
;freeware by www.gentlegiantstudios.com
(setq decplaces (getint "number of decimal places to keep: "))
(setq dfile (getfiled "STL output" "" "stl" 1))
(setq ofile (open dfile "w"))
(write-line "solid ASCII" ofile)
(setq c 0)
(setq ss (ssget "X" '((0 . "3DFACE"))) )
(setq c 0)
(setq ent (ssname ss c))
(while ent
(setq one_ent (entget ent))
;get vertices of 3dface
(setq a1 (assoc '10 one_ent))
  (setq a1 (cdr a1))
  (setq ax1 (car a1))
  (setq ay1 (cadr a1))
  (setq az1 (caddr a1))
(setq a1 (assoc '11 one_ent))
  (setq a1 (cdr a1))
  (setq ax2 (car a1))
  (setq ay2 (cadr a1))
  (setq az2 (caddr a1))
(setq a1 (assoc '12 one_ent))
  (setq a1 (cdr a1))
  (setq ax3 (car a1))
  (setq ay3 (cadr a1))
  (setq az3 (caddr a1))
(setq a1 (assoc '13 one_ent))
  (setq a1 (cdr a1))
  (setq ax4 (car a1))
  (setq ay4 (cadr a1))
  (setq az4 (caddr a1))
;got three sets of vertices, IGNORING FOURTH
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++
(setq nx (*(- ax1 ax2) (- ax2 ax3)))
(setq ny (*(- ay1 ay2) (- ay2 ay3)))
(setq nz (*(- az1 az2) (- az2 az3)))

(setq normal (strcat "facet normal " (rtos nx 1 decplaces) " " (rtos ny 1
decplaces) " " (rtos nz 1 decplaces)))
(write-line normal ofile)
(write-line "outer loop" ofile)
(setq vertex (strcat "vertex " (rtos ax1 1 decplaces) " " (rtos ay1 1
decplaces) " " (rtos az1 1 decplaces)))
(write-line vertex ofile)
(setq vertex (strcat "vertex " (rtos ax2 1 decplaces) " " (rtos ay2 1
decplaces) " " (rtos az2 1 decplaces)))
(write-line vertex ofile)
(setq vertex (strcat "vertex " (rtos ax3 1 decplaces) " " (rtos ay3 1
decplaces) " " (rtos az3 1 decplaces)))
(write-line vertex ofile)
(write-line "endloop" ofile)
(write-line "endfacet" ofile)
(setq test (+ ax4 ay4 az4))
(setq test2 (+ ax3 ay3 az3))
(if (/= test test2); deal with fourth vertex
(progn
(setq normal (strcat "facet normal " (rtos nx 1 decplaces) " " (rtos ny 1
decplaces) " " (rtos nz 1 decplaces)))
(write-line normal ofile)
(write-line "outer loop" ofile)
(setq vertex (strcat "vertex " (rtos ax1 1 decplaces) " " (rtos ay1 1
decplaces) " " (rtos az1 1 decplaces)))
(write-line vertex ofile)
(setq vertex (strcat "vertex " (rtos ax3 1 decplaces) " " (rtos ay3 1
decplaces) " " (rtos az3 1 decplaces)))
(write-line vertex ofile)
(setq vertex (strcat "vertex " (rtos ax4 1 decplaces) " " (rtos ay4 1
decplaces) " " (rtos az4 1 decplaces)))
(write-line vertex ofile)
(write-line "endloop" ofile)
(write-line "endfacet" ofile)
)
)
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++
(setq c (1+ c))
(setq ent (ssname ss c))
);end while
(write-line "endsolid ascii" ofile)

(setq ss nil); free up ssel
(close ofile)
)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
END OF LISP ROUTINE

For more information about the rp-ml, see http://ltk.hut.fi/rp-ml/

For more information about the rp-ml, see http://ltk.hut.fi/rp-ml/



This archive was generated by hypermail 2.1.2 : Tue Jun 05 2001 - 23:03:47 EEST