Good Afternoon All,
Trying to get this macro to run. Seems like it should be fairly simple, but can't wrap my Peabrain around it.
The first block runs, the second block runs, can't get it to run as a whole. Any help would be greatly appreciated.
FUNCTION Main() {
CREATE FOLDER "Toolpath" ;
ACTIVATE FOLDER "Toolpath\Folder1"
RENAME FOLDER "Toolpath\Folder1"
}
FOREACH toolpath IN folder ("TOOLPATH") {
STRING $Path = dirname(pathname(toolpath))
IF $Path == 'Toolpath' {
EDIT FOLDER ; INSERT $toolpath LAST
}
}
DEACTIVATE FOLDER
Solved! Go to Solution.
Solved by TK.421. Go to Solution.
Solved by urizenYHS3W. Go to Solution.
Solved by TK.421. Go to Solution.
put everything inside your main()
FUNCTION Main() {
CREATE FOLDER "Toolpath" ;
ACTIVATE FOLDER "Toolpath\Folder1"
RENAME FOLDER "Toolpath\Folder1"
FOREACH toolpath IN folder ("TOOLPATH") {
STRING $Path = dirname(pathname(toolpath))
IF $Path == 'Toolpath' {
EDIT FOLDER ; INSERT $toolpath LAST
}
}
DEACTIVATE FOLDER
}
Thanks for the reply. I thought it was the brackets but couldn't get it.
Now it's holding up on line 7.
Wants to call the folder "STRING"?
ran it through the debugger. you have to take out the rename folder command in there & then use DOCOMMAND to create and activate it with a specific name. i tried the below and it works
FUNCTION Main() {
STRING fName = INPUT "Enter Folder Name: "
STRING myCmd = "CREATE FOLDER" + '"Toolpath"' + $fName
DOCOMMAND $myCmd
$myCmd = "ACTIVATE FOLDER " + '"Toolpath\' + $fName + '"'
DOCOMMAND $myCmd
FOREACH tp IN folder ("TOOLPATH") {
STRING $Path = dirname(pathname(tp))
IF $Path == 'Toolpath' {
EDIT FOLDER ; INSERT $tp LAST
}
}
DEACTIVATE FOLDER
}
Hate to be a pain in the ass, but now it's holding up on line 4.
If it worked for you, I'm not sure what I'm doing wrong.
Running it through the ribbon, and the macro list. Same result.
hmmmm. i just ran it again and it ran fine. did you copy & paste everything that was in there?
Hey, sorry, I'd left for the day.
I'm sure I did copy everything. Deleted it all and copied again. This is what I've got.
Closed my session, reopened, and tried again. I got the same result.
Running it out of the "Choose" button. it gets as far as naming the folder, but doesn't create it.
Holds up here again on line 4?
I did try running it again through the macro list.
Same result.
I'm running 2023 Ultimate without the updates. Don't think that matters though, the macro should run on much older versions too.
I really appreciate the help. Any other suggestions would be great.
huh... i'm at a loss! I retyped the whole thing and ran it again & i have success. run it through the macro debugger step by step and see what you get
try something simple to see if it runs:
Ok, thanks for the help, I'll do that.
May the Force be with you!
i'll keep thinking too. lmk what the debugger shows you. maybe @Sean571 has an idea??
Running it through now. Same result. It holds up on line 4.
ah-HA! it does not like the space in the folder name. put an underscore or hyphen or camel case (drillingBottom) and you'll be golden
OH YAA!!
That's funny. Silly thing.
Thanks again for your help. Greatly appreciated!
I don't know why you are using DOCOMMAND as the CREATE FOLDER command accepts variables.
Since 2012.
DOCOMMAND was add in the first instance to handle any commands that didn't accept variables. But quickly the most of commands were updated to allow variables. There may be a handful left where DOCOMMAND is needed. As I recall most uses originally were to handle something like PRINT = Block.Limits.$par because people didn't know that you could do PRINT = Block.Limits[$par]
Interesting, I didnt know that! @Beta_Librae you can shorten your code using this:
Good Morning!
Thanks for the update.
I was happy with the code that you'd provided me first. Wasn't gonna change it because I'd created for most of the folders in the explorer. The only reason I did was because it gave the ability to use spaces in the name. That was nice.
This was a group of macros that I'd come across on here years ago. Can't remember who posted it. It gave the ability to create and name folders. I wanted to take it a step further and have it drag unfoldered entities into that named folder. With your help I think it works pretty well, so I'd like to share it all on here now.
I run it from a macro button on the ribbon called "Choose"
Hopefully other think it's a cool like I do and get some use out of it.
Thanks! I'll add this to my right click menu! I didnt think to try it with spaces; glad to know that works!
Can't find what you're looking for? Ask the community or share your knowledge.