Jump to content

Script to import a cad assembly and export as an stl for 3d printing.


Recommended Posts

Hi , i am using a script which imports a .catpart from a nominated folder

image.png.4bfa9df8f911c5a9f89eac5168e879c9.png

the CAD part is made up of multiple components

image.png.f4c33624757f6ee72f3774861858c176.png

and then i export in stl format and select 'multiple parts' ready for 3d printing. Each component of the .catpart then is assigned the name of the original part with externsion 00 , 01 , 02 etc.

image.png.22590c8d43c1541f9ac51339bf82aff0.png

is there a way of naming each stl as the components listed under the main CAD part?  

image.png

Hello Phil,

maybe something like this will help you...

# -*- coding: utf-8 -*-

import gom

# Default directory
DIR = 'C:/tmp/'

# loop over all parts
for part in gom.app.project.parts:
	
	# loop over all bodies
	for body in part.nominal.bodies:
		
		# get the name of the body
		name = body.name
		
		# export the body into a stl file with the name of the body
		gom.script.sys.export_stl (
			bgr_coding=False, 
			binary=True, 
			color=False, 
			elements=body, 
			export_in_one_file=True, 
			export_stages_mode='current', 
			file=DIR+name+'.stl', 
			length_unit='default', 
			set_stl_color_bit=False)

 

  • 4 weeks later...
×
×
  • Create New...