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

Dirname

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
john_lute
417 Views, 7 Replies

Dirname

I have a toolpath inside a setup and Im looking for the pathname.

I am able to do this with a toolpath inside a toolpath folder, but I am not able to inside a setup.

 
STRING folder = dirname(pathname('toolpath',$rev))
 
 
 
 
 
 

 

 

7 REPLIES 7
Message 2 of 8
rafael.sansao
in reply to: john_lute

STRING folder = dirname(pathname('setup','1'))

Rafael Sansão

EESignature

Message 3 of 8
john_lute
in reply to: john_lute

Thankyou for the suggestions, but that was not successful. 

Here are some examples of my setup and toolpath folders.

john_lute_0-1708372720014.png

In the command window when I type 

john_lute_1-1708372812023.png

  

Next is the toolpath folder example

john_lute_2-1708372852460.png

 

john_lute_4-1708373013795.png

Im looking for the location of the toolpath. The folder/setup name the toolpath is located in sets up my post options.

Message 4 of 8
rafael.sansao
in reply to: john_lute

I'm not sure I understand what you need. This should help you:

 

STRING $tpName = "1"

IF NOT entity_exists(entity("Toolpath",$tpName)) {
	MESSAGE WARN "Toolpath does not exist"
	MACRO ABORT
}

STRING $folder = ""
FOREACH set IN FOLDER("Setup") {
	FOREACH ent IN components($set) {
		IF lcase(ent.RootType) == 'toolpath' {
			IF $ent.Name == $tpName {
				$folder = dirname(pathname('setup',$set.Name))
				
				STRING $msg = "Setup pathname: " + $folder + CRLF + "Setup name: " + $set.Name + CRLF + "Toolpath name: " + $tpName
				MESSAGE INFO $msg
				
				BREAK
			}
		}
	}
}

IF $folder == "" {
	$folder = dirname(pathname('Toolpath',$tpName))
	
	STRING $msg = "Toolpath pathname: " + $folder + CRLF + "Toolpath name: " + $tpName
	MESSAGE INFO $msg
}

 

Rafael Sansão

EESignature

Message 5 of 8
icse
in reply to: rafael.sansao

Why you use the lowercase function in the if statement?

IF lcase(ent.RootType) == 'toolpath' {

is the root type in some cases different?

Message 6 of 8
john_lute
in reply to: john_lute

Thank you for you feedback, but that is not what I'm after.

When I have a toolpath selected using explore select, I need to know which folder the toolpath is located in. Here is the code that works when the toolpath is in a toolpath folder. When I place inside a Setup, the code does not work.

 

//////////// Explorer Stuff///////////////////////
// Removes selected items from explorer variable
EXPLORER SELECT TOOLPATH ROOT
Macro Pause "Select Desired Toolpaths"
IF is_empty(explorer_selected_entities()) {
 
Macro Pause "Make sure to select your toolpaths"
 
}
 
 
// Loops Through Toolpaths
FOREACH item_z IN explorer_selected_entities() {
 
ACTIVATE Toolpath $item_z
 
 
string DIRPath=dirname(pathname(entity('toolpath','')))
 
Macro Pause $DIRPath
}
 
 
Message 7 of 8
rafael.sansao
in reply to: john_lute

Try this:

EXPLORER SELECT TOOLPATH ROOT
Macro Pause "Select Desired Toolpaths"
IF is_empty(explorer_selected_entities()) {
	Macro Pause "Make sure to select your toolpaths"
}

// Loops Through Toolpaths
FOREACH item_z IN explorer_selected_entities() {
	ACTIVATE Toolpath $item_z

	STRING $folder = ""
	FOREACH set IN FOLDER("Setup") {
		FOREACH ent IN components($set) {
			IF lcase(ent.RootType) == 'toolpath' {
				IF $ent.Name == $item_z.Name {
					$folder = dirname(pathname('setup',$set.Name))
					STRING $msg = "Setup pathname: " + $folder + CRLF + "Setup name: " + $set.Name + CRLF + "Toolpath name: " + $item_z.Name
					MESSAGE INFO $msg
					
					BREAK
				}
			}
		}
	}

	IF $folder == "" {
		$folder = dirname(pathname('Toolpath',$item_z.Name))
		
		STRING $msg = "Toolpath pathname: " + $folder + CRLF + "Toolpath name: " + $item_z.Name
		MESSAGE INFO $msg
	}
}


@icse 
I don't think so (maybe in older versions?). My memory is bad and I copied this excerpt from the manual 😃

Rafael Sansão

EESignature

Message 8 of 8
john_lute
in reply to: john_lute

Thank you, I used a portion of your example to solve my problem.

When you shared your fix on this forum, what method did you use to show the work. Is it and attached Notepad++ Document, or another method.

 

Here is what I used, thanks again.

//////////// Explorer Stuff///////////////////////
// Removes selected items from explorer variable
EXPLORER SELECT TOOLPATH ROOT
 
Macro Pause "Select Desired Toolpaths"
 
IF is_empty(explorer_selected_entities()) {
 
Macro Pause "Make sure to select your toolpaths"
 
}
 
// Loops Through Toolpaths
FOREACH item_z IN explorer_selected_entities() {
ACTIVATE Toolpath $item_z
 
string DIRPath = ""
FOREACH set IN FOLDER("Setup") {
FOREACH ent IN components($set) {
IF lcase(ent.RootType) == 'toolpath' {
IF $ent.Name == $item_z.Name {
 
$DIRPath = $set.Name
 
BREAK
}
}
}
}

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

Post to forums  

Autodesk Design & Make Report