Access Stamp UV mesh through scripting
Access Stamp UV mesh through scripting
Hi all!,
Does anyone know if theres a way to access Stamp UV through scripting? I'd really love to be able to script it so i could make it fit my workflow a little better.
Thanks
Pete
Does anyone know if theres a way to access Stamp UV through scripting? I'd really love to be able to script it so i could make it fit my workflow a little better.
Thanks
Pete
Re: Access Stamp UV mesh through scripting
Damn! I really hate the stamp uv workflow and I was really hoping I could make it into more of a one click type affair...
- Hirazi Blue
- Administrator
- Posts: 5107
- Joined: 04 Jun 2009, 12:15
Re: Access Stamp UV mesh through scripting
Just found this post by Stefan Kubicek on the Mailing List:
(Quoted from here, where you can find the plugin as an attachment)Kim Aldis once sent me a Python plugin for Softimage that would export a UV set as an EPS file for import into Photoshop. The nice thing is that the EPS will import into Pshop as lines and is thus resolution independant.
Stay safe, sane & healthy!
Re: Access Stamp UV mesh through scripting
Thanks Hirazi
Would love to see some kind of chrome-like addon marketplace, so many gems are scattered all over the web
Would love to see some kind of chrome-like addon marketplace, so many gems are scattered all over the web
- Hirazi Blue
- Administrator
- Posts: 5107
- Joined: 04 Jun 2009, 12:15
Re: Access Stamp UV mesh through scripting
Wow, thanks Hirazi, that sounds seriously cool!
(oh and of course Kim Aldis & Stefan Kubicek )
It's a bummer AD killed the softimage site they were starting back in early ice days, the Area just plain sucks.
rray is pretty much the go to spot for me now.
(oh and of course Kim Aldis & Stefan Kubicek )
Dude, that would be awesome. It's such a shame things are scattered so much.Would love to see some kind of chrome-like addon marketplace, so many gems are scattered all over the web
It's a bummer AD killed the softimage site they were starting back in early ice days, the Area just plain sucks.
rray is pretty much the go to spot for me now.
- Hirazi Blue
- Administrator
- Posts: 5107
- Joined: 04 Jun 2009, 12:15
Re: Access Stamp UV mesh through scripting
Before anyone else mentions it: the aforementioned Kim Aldis plugin
was already available on rray.de as well,
if only I had looked there first...
;)
was already available on rray.de as well,
if only I had looked there first...
;)
Stay safe, sane & healthy!
Re: Access Stamp UV mesh through scripting
Kim Aldis EPSexport never worked for me.
I may be wrong but it seems like it was written to export Camera image to EPS, not UVs.
But I can't even do that, it just doesn't write anything here.
I don't know how useful can this be to you but you can "type" through WSH.
Meaning you can activate a shortcut with your script.
Therefore, you can activate the Stamp UV Mesh through scripting.
Not very elegant, and obviously it won't work in a different PC with different shortcuts.
I was experimenting with this a while ago, but never actually done anything elaborated.
Let's asume you have a polygon selected, and this polygon has an UV.
As you can see, this script will write a temporal file in C:\ so you will need to have write permissions.
Anyway, if your short key for Stamp UV is Shift + S, you'll get a save image (stampUV) dialog with this script.
You can check here the WshShell SendKeys Codes:
http://www.devguru.com/technologies/wsh/quickref/wshshell_SendKeys.html
If you want to experiment with this, remember:
- The mouse cursor position affects the keyboard input.
- The normal keyboard input may get mixed with the script input.
Ex: Activate the script with CTRL + Click and if the release timing is not perfect, the CTRL key may get mixed with the scripted keyboard input (in this case it would become CTRL+Shift+S).
- You need to give the windows and actions some time to operate, that's why I added an improvised JScript Sleep.
The problem is that if the mouse is not over the Texture Editor when the Stamp UV command runs, it won't work.
I mean, the Shift+S input will work but outside the Texture Editor so you may be opening Camera Visibility.
I don't know how to force XSI to focus on the recently opened Window and ignore the mouse position so a workaround I'm applying here is to create a VBS file in C:\ to Sleep a little between commands and it seems to work.
I tried with a JScript "while date" sleep method without good results, so maybe the key is not the time delay, I don't know.
Python Time.Sleep results are worst, it just delay the whole process, but it may be because of my limited Python knowledge.
I may be wrong but it seems like it was written to export Camera image to EPS, not UVs.
But I can't even do that, it just doesn't write anything here.
I don't know how useful can this be to you but you can "type" through WSH.
Meaning you can activate a shortcut with your script.
Therefore, you can activate the Stamp UV Mesh through scripting.
Not very elegant, and obviously it won't work in a different PC with different shortcuts.
I was experimenting with this a while ago, but never actually done anything elaborated.
Let's asume you have a polygon selected, and this polygon has an UV.
Code: Select all
//JScript
var WshShell = new ActiveXObject("WScript.shell")
// If the Texture Editor is already opened, close it!
// I don't know how to make it work with an already opened Texture Editor so I decided to close it.
var views = Application.Desktop.ActiveLayout.Views
for (var i=0, a=views.count; i< a; i++){
if (views(i).name == "Texture Editor"){
views(i).state = siClosed;
}
}
Sleep(0.00001) // it usually works with 0 too, but just in case
// Open the Texture Editor
OpenView ("Texture Editor")
Sleep(0.00001)
// Now type some keys!
// "+s" = Shift S
WshShell.SendKeys ("+s")
//------------
function Sleep(seconds){
// Creating the VBS Sleep File in C:\
var FSO = new ActiveXObject("Scripting.FilesystemObject");
var VBSleep = FSO.CreateTextFile("C:\\vbsleep.vbs", true);
VBSleep.WriteLine("dim mult : mult = wscript.Arguments.Item(0)");
VBSleep.WriteLine("wscript.sleep 1000 * mult");
VBSleep.Close();
// Calling VBS Sleep
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.run("C:\\vbsleep.vbs " + seconds, 2, 1)
FSO.DeleteFile("C:\\vbsleep.vbs")
}
Anyway, if your short key for Stamp UV is Shift + S, you'll get a save image (stampUV) dialog with this script.
You can check here the WshShell SendKeys Codes:
http://www.devguru.com/technologies/wsh/quickref/wshshell_SendKeys.html
If you want to experiment with this, remember:
- The mouse cursor position affects the keyboard input.
- The normal keyboard input may get mixed with the script input.
Ex: Activate the script with CTRL + Click and if the release timing is not perfect, the CTRL key may get mixed with the scripted keyboard input (in this case it would become CTRL+Shift+S).
- You need to give the windows and actions some time to operate, that's why I added an improvised JScript Sleep.
The problem is that if the mouse is not over the Texture Editor when the Stamp UV command runs, it won't work.
I mean, the Shift+S input will work but outside the Texture Editor so you may be opening Camera Visibility.
I don't know how to force XSI to focus on the recently opened Window and ignore the mouse position so a workaround I'm applying here is to create a VBS file in C:\ to Sleep a little between commands and it seems to work.
I tried with a JScript "while date" sleep method without good results, so maybe the key is not the time delay, I don't know.
Python Time.Sleep results are worst, it just delay the whole process, but it may be because of my limited Python knowledge.
Last edited by myara on 15 Feb 2012, 11:36, edited 2 times in total.
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
Re: Access Stamp UV mesh through scripting
Hey myara!
Yeah I unfortunately spoke too soon with the EPS script, I had the same probs so it didn't work out for me.
Your script worked though so thanks heaps!!
I tried to add to the script to hopefully get it to put in a filename with this -But that just seemed to make the whole thing stop. Any ideas?
Thanks again for the help, glad im not the only one that finds it annoying
Pete.
Yeah I unfortunately spoke too soon with the EPS script, I had the same probs so it didn't work out for me.
Your script worked though so thanks heaps!!
I tried to add to the script to hopefully get it to put in a filename with this -
Code: Select all
// Now type some keys!
// "+s" = Shift S
WshShell.SendKeys ("+s");
Sleep(.1);
WshShell.SendKeys ("stamp.png");
Thanks again for the help, glad im not the only one that finds it annoying
Pete.
Re: Access Stamp UV mesh through scripting
It seems that StampUV doesn't like my vbsSleep
But it works without it, try this:
I'm starting to get XSI Crashes when the Sleeps are too short, so I incremented them to 0.01 and 0.1 seconds.
You will have to manually click on "OK" to confirm overwriting, specify compression, etc.
I still haven't found a solution to this, but now I really got to get back to work
Good Luck
But it works without it, try this:
Code: Select all
//JScript
var WshShell = new ActiveXObject("WScript.shell")
// If the Texture Editor is already opened, close it!
// I don't know how to make it work with an already opened Texture Editor so I decided to close it.
var views = Application.Desktop.ActiveLayout.Views
for (var i=0, a=views.count; i< a; i++){
if (views(i).name == "Texture Editor"){
views(i).state = siClosed;
}
}
CreateSleep(0) // Create vbsSleep
Sleep(0.01)
// Open the Texture Editor
OpenView ("Texture Editor")
Sleep(0.1)
// Now type some keys!
// "+s" = Shift S
WshShell.SendKeys ("+s");
WshShell.SendKeys ("stamp"); // specify your file name
WshShell.SendKeys ("{TAB}"); // tab to change focus to the extension drop menu
WshShell.SendKeys ("png"); // your file extension
WshShell.SendKeys ("{ENTER}"); // Enter
CreateSleep(1) // Delete vbsSleep
//------------
function CreateSleep(option){
var FSO = new ActiveXObject("Scripting.FilesystemObject");
if(option==0){
// Creating the VBS Sleep File in C:\
var VBSleep = FSO.CreateTextFile("C:\\vbsleep.vbs", true);
VBSleep.WriteLine("dim mult : mult = wscript.Arguments.Item(0)");
VBSleep.WriteLine("wscript.sleep 1000 * mult");
VBSleep.Close();
}
else if (option==1){
FSO.DeleteFile("C:\\vbsleep.vbs")
}
}
function Sleep(seconds){
// Calling VBS Sleep
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.run("C:\\vbsleep.vbs " + seconds, 2, 1)
}
You will have to manually click on "OK" to confirm overwriting, specify compression, etc.
I still haven't found a solution to this, but now I really got to get back to work
Good Luck
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
Re: Access Stamp UV mesh through scripting
Hey Myara,
I grabbed your already hacky code and made it into some kind of crazy hack monster!
Sure, it could use some serious ironing out but it works for me!
Here's a few notes -
So you select an object and run the script
You then get these options
Then it (hopefully) pops out an image file based on those options. (into your project/pictures directory)
Here's the script -
WARNING - this script is really hacky, maybe save your scene before using it
http://www.naffupdate.com/forumfiles/QuickStamp.js
Maybe have a look if you are feeling brave
I grabbed your already hacky code and made it into some kind of crazy hack monster!
Sure, it could use some serious ironing out but it works for me!
Here's a few notes -
So you select an object and run the script
You then get these options
Then it (hopefully) pops out an image file based on those options. (into your project/pictures directory)
Here's the script -
WARNING - this script is really hacky, maybe save your scene before using it
http://www.naffupdate.com/forumfiles/QuickStamp.js
Maybe have a look if you are feeling brave
Last edited by Pete on 17 Feb 2012, 09:53, edited 1 time in total.
Re: Access Stamp UV mesh through scripting
lol that's a hacky wacky monster code! kinda dangerous but I loved it
You may need to add some check routines like selection check, check if the Script folder exists, use OM instead of names like "DefaultLib" because the Current Lib may be different, but it seems to do the job done. Most of the time at least.
Since you are using a lot of commands you may want to disable the log to improve performance a little.
note : You don't need to change this value back
Oh, and a warning save scene now! option would be good too
You may need to add some check routines like selection check, check if the Script folder exists, use OM instead of names like "DefaultLib" because the Current Lib may be different, but it seems to do the job done. Most of the time at least.
Since you are using a lot of commands you may want to disable the log to improve performance a little.
Code: Select all
var prefs = Application.Preferences;
prefs.SetPreferenceValue( "scripting.cmdlog", false );
Oh, and a warning save scene now! option would be good too
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
Re: Access Stamp UV mesh through scripting
Haha, yeah!Oh, and a warning save scene now! option would be good too
It's kinda embarrassingly dodgy but funny at the same time and it gets the job done for me so i thought i should put it up here
Thanks for the help, i updated the script.
Pete
Re: Access Stamp UV mesh through scripting
Since the code leaves an object and 2 materials, how about this workaround:
If QuickStamp garbage is found, it will delete them and stop the script.
If no garbage is found, start QuickStamp.
So it would be a 2 step, 2 click process, but better than do it manually I guess.
Code: Select all
var quickobj = ActiveSceneRoot.FindChild("QuickStampObj")
if(quickobj){
DeleteObj(quickobj)
var oMatLibs = ActiveProject.ActiveScene.MaterialLibraries
for ( var i=0, a = oMatLibs.Count; i < a; i++ ) {
var oMats = oMatLibs(i).items
for ( var j=0, b = oMats.Count; j < b; j++ ) {
if (oMats(j).name.substr(0,14) =="QuickStampTemp"){
DeleteObj(oMats(j))
}
}
}
}
else{
// quick stamp code here
}
If no garbage is found, start QuickStamp.
So it would be a 2 step, 2 click process, but better than do it manually I guess.
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
Re: Access Stamp UV mesh through scripting
Hey thanks Myra,
I updated the script, this time the parameters are created on the QuickStamp object, So if you have to run the script again it re-uses the your last QuickStamp prefs.
I haven't added the material stuff yet (I'm scared ) The whole material/clip section was so finicky that I think i'll break something if I try to tweak it.
Hey I wasn't too sure what you meant earlier when you said
Thanks
Pete
I updated the script, this time the parameters are created on the QuickStamp object, So if you have to run the script again it re-uses the your last QuickStamp prefs.
I haven't added the material stuff yet (I'm scared ) The whole material/clip section was so finicky that I think i'll break something if I try to tweak it.
Hey I wasn't too sure what you meant earlier when you said
what's OM?use OM instead of names like "DefaultLib"
Thanks
Pete
Who is online
Users browsing this forum: No registered users and 64 guests