Jump to content
3D Coat Forums
coverman

[SCRIPT]GetCurrentToolID()

Recommended Posts

I write an easy script to get current tool ID.

-------------

void main(){

 string ID = GetCurrentToolID();

 ShowFloatingMessage(ID, 10);

}

-------------

 

This is the result.

VOX_SCULPT_TOOL::SCULP_GROW

 

I think this is the command ID!

-------------

bool cmd(string &in ID);

This is main command that you will use. It performs any action from user interface. To get the command ID hover 

your mouse cursor over required item and press MMB+RMB simultaneously. The command ID will be copied to 

clipboard. Pay attention that if a command is not present in current UV layout it will not be performed.

-------------

 

So I write two script.

cmd("$[Page4]Grow); //Yes!it is working! :)

cmd("$VOX_SCULPT_TOOL::SCULP_GROW); //No!it is not working. :(

 

What is the meaning of this command exists?

GetCurrentToolID();

Share this post


Link to post
Share on other sites

Hi!

Which version are you using ?

Share this post


Link to post
Share on other sites

I too am puzzled when it comes to a purpose of the GetCurrentToolID() function. The IsInTool(string) accepts commands (cmd) and not tool IDs that are returned by the GetCurrentToolID(). RMB+MMB on a tool also returns a command.

Looks like the values returned by GetCurrentToolID() function cannot be used anywhere. Maybe Andrew overlooked or forgot about it? Maybe they were supposed to work with IsInTool?

Did you write to Andrew?

 

PS. You can write a function that takes IDs and translates them into commands, but it doesn't make much sense when you can use commands directly.

 

void main(){
  setCurrentTool("VOX_SCULPT_TOOL::SCULP_FILL");
}

void setCurrentTool(string id){
  //Using array, because dictionary doesn't seem to work.
  array<array<string>> dict = {
    {"VOX_SCULPT_TOOL::SCULP_GROW", "$[Page4]Grow"},
    {"VOX_SCULPT_TOOL::SCULPT_SMOOTH","$[Page4]Smooth"},
    {"VOX_SCULPT_TOOL::SCULP_FILL","$[Page4]Fill"}
    // (...)
  };
  for(int i=0;i<dict.length();i++){
    if(dict[i][0]==id){
      cmd(dict[i][1]);
      break;
    }
  }
}
Edited by ajz3d

Share this post


Link to post
Share on other sites
Thanks to your reply and script ajz3d.

I also agree with your opinion.

 

The values returned by GetCurrentToolID() is very accurate but cannot be used anywhere.

The ID is clearly translated like this.

"VOX_SCULPT_TOOL::SCULP_GROW" to "$[Page4]Grow"

 

So if we want to get ID  and change Tool with a script, we need retranslation like your script.

I was just surprised.Really!? :blink:

 

I just have a surprise, but I'm not troubled at all.

So I do not send any mail to Andrew.

 

I prefer this type string ID "VOX_SCULPT_TOOL::SCULP_GROW"

It's long, but it looks like common format in 3D-Coat and accurate. :)

Share this post


Link to post
Share on other sites

thanks for this you guys.

I made myself an increase and decrease density script and bound it to a hotkey,  it kept selecting the transform tool and I used your script to reselect the current tool.

 

giving as I get:

 

// this script degrades the current layer by 2 and keeps the active tool.  
// used for a quick "degrade" current vox layer hotkey.


void setCurrentTool(string id){
	array<array<string>> dict = {
		{"VOX_SCULPT_TOOL::SCULP_GROW", "$[Page4]Grow"},
		{"VOX_SCULPT_TOOL::SCULPT_SMOOTH","$[Page4]Smooth"},
		{"VOX_SCULPT_TOOL::SCULP_FILL","$[Page4]Fill"}
		// (...)
	};
	for(int i=0;i<dict.length();i++){
		if(dict[i][0]==id){
			cmd(dict[i][1]);
			break;
		}
	}
}


void main(){
	
	// make sure we're in the sculpting room
	if(!IsInRoom("Sculpt")){
	  ToRoom("Sculpt");
	  Step(1);
	}
	
	//store current layer name
	string CurrentVoxLayer =  GetCurVolume();
	
	// rename it
	RenameCurVolume("DELETE_ME");
	
	// store the current tool
	string CurrentToolID = GetCurrentToolID();
	
	// clone and degrade the current layer by 2
	cmd("$VoxTreeBtn7");
	
	// name it the same.
	RenameCurVolume(CurrentVoxLayer);
	
	// delete the old layer.
	SetCurVolume("DELETE_ME");
	cmd("$VoxTreeBtn1");
	
	//select the new layer just in case
	SetCurVolume(CurrentVoxLayer);
	Step(1);
	
	// recall the tool so you're not in transform mode.
	setCurrentTool(CurrentToolID);

}

 

Edited by Spiraloid
  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×