Community
PowerShape Forum
Welcome to Autodesk’s PowerShape Forums. Share your knowledge, ask questions, and explore popular PowerShape topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Powershape Macro Help

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
TK.421
2415 Views, 6 Replies

Powershape Macro Help

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!

--------------------------------------
the numbers never lie
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: TK.421

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

Message 3 of 7
rafael.sansao
in reply to: TK.421

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

EESignature

Message 4 of 7
TK.421
in reply to: TK.421

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

Capture.PNGCapture1.PNG

 

thank you both!

--------------------------------------
the numbers never lie
Message 5 of 7
Anonymous
in reply to: TK.421

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

Message 6 of 7
TK.421
in reply to: Anonymous

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

--------------------------------------
the numbers never lie
Message 7 of 7
Anonymous
in reply to: TK.421

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. Smiley Indifferent

 

 

 

Mateusz

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report