Notifications
Clear all

[Closed] spinner to control number of sections to export

Sorry if this is a redundant post but I could not find much about this particular issue:
I would like to use a loop to export a number of sections to individual.dwg files the number and z transform value of splines depending on the value of a spinner.
How do you instruct to create sections with increasing transform z values with a step = 1, then exporting a corresponding number of external files? Files should be named using a suffix but I have no idea how to do it with exportFile.
e.g. when the spinner value is set to 2 I would export 2 files (plan01 and plan02) with splines located at z=1 and z=2.

Thank you in advance for any help.

rollout a "DWG Extraction Assistant" width:168 height:100
(
	spinner spn1 range:[0,10,2] type:#integer
	label lbl1 "number of sections"
	button btn1 "export file(s)" width:120 height:24
	on btn1 pressed  do
	(
		for i = 1 to spn1.value do
		(
			s = section length:1000 width:1000 pos:[0,0,spn1.value] isSelected:on
			redrawViews()
			convertToSplineShape s
			select $section* -- select all sections
			exportFile ("C:\	emp\\plan.dwg") #noPrompt selectedOnly:True -- export selected objects to dwg file
		)
	)
)
createDialog a
5 Replies

I figured out the first problem at line 10:
s = section length: 1000 width: 1000 pos:[0,0,i] isSelected:on

I am now looking into options for exportFile in regards to saving out multiple files with a suffix: plan01, plan02…

Thanks for any advice!

at line 14 I am now trying the following:
exportFile (“C:\ emp\” + getFileNameFile (i) + “.dwg”)

note that i is the number of the cycle used in the spinner. Maxscript does not recognize the index variable (i) and returns the following:
–Unable to convert: 1 to type: FileName
:shrug:
I appreciate any help.

ok, getFilenameFile makes no sense.
I am now looking into a getLoopIndex (?) which does not exist…

i is a number in your loop, you have to convert it to a string before you can use it as a file name.
I’m not sure what you’re trying to do with getFileNameFile()

I think this is what you need:
exportFile (“C:\ emp\”+(i as string)+”.dwg”)

Thank you Marc. It all works now!