I'm new to powershape, and to powershape macros. I need a bit of help here: I'd like to be able to export my surfaces to a folder within the model path. Where I'm stuck is stripping off from the path the model name, and adding a folder to save in. What are the commands I should use? I've spent sometime searching the old forum and the powershape help. Here's what I have:
INPUT TEXT 'Enter File Name' $filename
LET modname = model.path
the above line returns "X:/Job Number/25027/Powershape Model.psmodel" I would like to change this to "X:/Job Number/25027/Export\$filename"
QUICK QUICKSELECTSURFONLY
FILE EXPORT WIZARD
NEXT
file path name
WIZEXPORT
Dismiss
Any help is appreciated, thanks!
Solved! Go to Solution.
Solved by rafael.sansao. Go to Solution.
Try this:
// Project path // INPUT TEXT 'Enter File Name' $filename LET modname = model.path LET modnamePath = ' ' LET modnameFilename = ' ' LET modnameLength = length($modname) LET slashIndex = $modnameLength WHILE $slashIndex { IF ($modname[$slashIndex]) == '/' { BREAK } LET $slashIndex = $slashIndex - 1 } IF $slashIndex <= 1 { RETURN } ELSE { LET modnamePath = RANGE($modname; 1; $slashIndex) LET modnameFilename = RANGE($modname; $slashIndex; $modnameLength) LET modnameExport = concat($modnamePath;'Export';$modnameFilename) } LET message = concat('Model export path: '; $modnameExport) PRINT ERROR $message
Mateusz
INPUT TEXT 'Enter File Name' $filename LET $S = RANGE(model.path; 1; length(model.path) - length(model.selected) - 8) LET $full = concat($S;'Export/';$filename)
Rafael Sansão
Thank you both for your replies. I went with rafael's code on this because it's a lot shorter; but when i have more time, i will dissect both codes to try to learn powershape macros better as it looks like i'll be using powershape more... with that said, i need a little more help to bring this home. the code returns the correct file path i'm looking to use, but gives me an message box saying supplied path is invalid. what is the command to enter the path and file name for exporting? I did add a file extension to the $full variable
INPUT TEXT 'Enter File Name' $filename LET $S = RANGE(model.path; 1; length(model.path) - length(model.selected) - 8) LET $full = concat($S;'Export/';$filename; '.step') PRINT ERROR $full QUICK QUICKSELECTSURFONLY FILE EXPORT WIZARD WIZEXPORT TARGET UNKNOWN FILE EXPORT $full NEXT Dismiss
thank you both!
Should work:
INPUT TEXT 'Enter File Name' $filename LET $S = RANGE(model.path; 1; length(model.path) - length(model.selected) - 8) LET $full = concat($S;'Export/') PRINT ERROR $full IF !(directory[$full].exists) { FILE CREATE DIR $full } QUICK QUICKSELECTSURFONLY LET expCommand = concatenate('file export '; $full; $filename; '.step') EXECUTE COMMAND $expCommand
Mateusz
Thats great, thanks so much!
Is the Execute Command similar to the Do Command in powermill? As I understand the Do Command, that is a way to back door a solution when the language doesnt quite support what you want to do. Is that the case here, or is Execute Command a commonly used thing in Powershape?
thanks again to both of you
Your welcome.
@TK.421 wrote:
Is the Execute Command similar to the Do Command in powermill?
Yes.
@TK.421 wrote:
As I understand the Do Command, that is a way to back door a solution when the language doesnt quite support what you want to do.
Something like that. But I can't tell you when you should use 'execute command'. I always do it by trial and error method.
@TK.421 wrote:
Is that the case here, or is Execute Command a commonly used thing in Powershape?
I don't understand.
Mateusz
Can't find what you're looking for? Ask the community or share your knowledge.