headus 3D tools headus 3D tools / 3D scans
Support Forums
 
 FAQFAQ   SearchSearch    UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
headus 3D scans

Could I get automation with uvlayout
Goto page 1, 2  Next
 
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hnzhang



Posts: 7
Joined: 08 Oct 2010

PostPosted: Fri Oct 08, 2010 2:24 pm    Post subject: Could I get automation with uvlayout Reply with quote

we are using uvlayout in house right now, and artists are asking for a crazy feature with the following steps,
1. send a group of geometries to headus from Maya.[ of course, yes]
2. UVLayout will do pack all automatically without user intervention in UVLayout.
3. UVLayout will send these geometries back to maya automatically without user intervention in UVlayout.

That means artists have no any operation in UVLayout, and UVlayout works as a engine in backend.
Back to top
View user's profile Send private message
headus
Site Admin


Posts: 2871
Joined: 24 Mar 2005
Location: Perth, Australia

PostPosted: Fri Oct 08, 2010 7:35 pm    Post subject: Reply with quote

Yes, completely crazy, but you should be able to do that via the plugin interface, which is described here ...

http://www.headus.com/phpbb/viewtopic.php?t=159

If you scroll down to the "Other commands" section you'll see that you can get UVLayout to cut edges, detach and drop shells, then flatten, optimize and save out, all with no user interaction.

Its been a while since I've tested some of those other commands, so if you have any problems getting it to work, don't give up ... just let me know and I'll fix anything that's broken.

Phil
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hnzhang



Posts: 7
Joined: 08 Oct 2010

PostPosted: Tue Oct 12, 2010 1:01 pm    Post subject: About automatically "Pack All" Reply with quote

Hi Phil,
It is exciting to get positive reply saying it is doable.

By giving more details, I believe you can help me better.
1.This is for lightmapping workflow.
2. we have legacy assets created before. Lightmap uvs were created and packed for grouped geometries sharing with the same lightmap file
3. what we want from Headus is to utilize super smart pack all function to repack all grouped geometries based on existing UV. When grouped geometries are loaded into headus, most of time, simply clicking on "pack all" button will result a satisfactory result.

That is why we would like to automate the whole process.

I followed the instruction in this page(http://www.headus.com/phpbb/viewtopic.php?t=159), and did not find exact cmd for "pack all". is it not mentioned there, or I have to restudy the page.?

Many thanks.
Back to top
View user's profile Send private message
hnzhang



Posts: 7
Joined: 08 Oct 2010

PostPosted: Tue Oct 12, 2010 2:58 pm    Post subject: Reply with quote

the cmd file,
Suppose "Pack All" can be sent to uvlayout from Maya successfully, and I have to ask uvlayout to save file so that Maya can load it back. roughly the cmd file will look like(with psudeo uvlayout cmds),

packall
sendback

but I really don't know what is the exact cmds from uvlayout.

I tried drop, and it is not what I want.
Back to top
View user's profile Send private message
headus
Site Admin


Posts: 2871
Joined: 24 Mar 2005
Location: Perth, Australia

PostPosted: Tue Oct 12, 2010 7:37 pm    Post subject: Reply with quote

OK, to just do the pack and nothing else, we need to go into undocumented territory. We're going to use low level GUI commands; there's too many of them to document, and they can change, but this will most likely work for a long while yet.

1] So first up, create a text file with these two lines in it ...

run UVLayout|Pack|Pack All
run UVLayout|Plugin|Save

2] Next, start UVLayout in plugin mode in the usual way ...

uvlayout -plugin,Poly,Edit plugin.obj

... and its at this point that you need to manually set the pack parameters in the GUI (e.g. if you want to try rotating shells for better packing, the pack quality, if you want to align shells to the axes etc). Sorry, there's no way currently to set these through the command file, but you only have to do it once for each batch of files that you want to process.

3] So once you've decided on the pack settings, load in the first mesh by copying it to "plugin.obj". UVLayout should automatically load the file in Edit mode, so all existing UVs are preserved.

4] Next, copy the text file from step 1] into "plugin.cmd". UVLayout should automatically pack all shells according to the parameters you set in the GUI, and when its done, the result is written to "plugin.out". Your controlling application needs to watch for this file to know when UVLayout has finished.

To repeat on other meshes, just keep cycling through steps 3] and 4].

Phil
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hnzhang



Posts: 7
Joined: 08 Oct 2010

PostPosted: Wed Oct 13, 2010 7:48 am    Post subject: Reply with quote

that works. really cool.
Great job, Phil
Back to top
View user's profile Send private message
hnzhang



Posts: 7
Joined: 08 Oct 2010

PostPosted: Mon Oct 18, 2010 2:28 pm    Post subject: Reply with quote

I got a disturbing issue with this right now.
For example, give 5 lightmap groups(grp1, grp2, ...grp5). it works perfect on the 1st lightmap grp1. however, for grp2, maya gets wrong geometries back from uvlyaout, which actually are the ones sent to uvlayout in grp1.

However, with the same code, if I $SelectedGroups as only one lightmap group, the code works perfectly.

any idea? it seems uvlayout needs a break btw lightmap group to change its breath Smile

my code looks like the following roughly,
proc automation()
{
for($lmGrp in $SelectedGroups){
string $geos[] = getGeosinLMGrp($lmGrp);
select -r $geos;
uvlayout_send();//this is changed
}
}

//changed uvlayout_send()
{
....
uvlayout_set( $uvlayout_subdiv ? "SUBD" : "Poly");
uvlayout_cmd( "run UVLayout|Pack|Pack All\nrun UVLayout|Plugin|Save");

//delete
sysFile -delete $uvlayout_loadname;
uvlayout_mv( $uvlayout_tempname, $uvlayout_savename);

delete $uvlayout_exported;
if( $HeadusAutomation ){//if automation is required, wait until headus finishes it work.
progressWindow - title "Auto Packing Lightmap UV"
-progress 0
-status "Waiting result from Headus... Please ESC to cancel"
-isInterruptable true;
int $cancelled = 0;
pause -seconds 5;

while(!`filetest -w $uvlayout_loadname`){//wait until uvlayout finishes it job
if ( `progressWindow -query -isCancelled` ){
$cancelled = 1;
break;
}
pause -seconds 1;
}
progressWindow -endProgress;
if($cancelled ==0){
print("\n uvlayout_send: To load result back...\n");
uvlayout_loadfile($uvlayout_loadname,$uvlayout_exported, $uvlayout_selected );// which is very similar to uvlayout_load
}
}
}
....
}
Back to top
View user's profile Send private message
headus
Site Admin


Posts: 2871
Joined: 24 Mar 2005
Location: Perth, Australia

PostPosted: Mon Oct 18, 2010 6:06 pm    Post subject: Reply with quote

The only obvious thing I can spot there is that you're creating the command file before the geometry file, but it should be the other way around. Create or copy the command file after you've done that uvlayout_mv() call, with maybe a 1 second pause in between.

By the way, if you add "-debug" to the uvlayout command line (before the "-plugin" arg) then it'll write out some trace calls, showing you whats its thinking when running in plugin mode.

Phil
Back to top
View user's profile Send private message Send e-mail Visit poster's website
headus
Site Admin


Posts: 2871
Joined: 24 Mar 2005
Location: Perth, Australia

PostPosted: Tue Oct 19, 2010 1:32 am    Post subject: Reply with quote

I thought I should actually test this myself and came across the same problem!

Whats going on is that UVLayout is over-paranoid about infinite load loops when in plugin mode (it sometimes happened in the early days) so its detected this auto processing as a loop and doesn't load in the second file. The first file just gets repacked and saved out again.

What you need to do is wait 6 seconds after you detect the result back from UVLayout before sending a new file. That gives UVLayout enough time to calm down and be ready to work again.

FYI, here's a shell script that packs all OBJ files listed on the command line, and it really works! You can study it to work out the same sequences and timings for your mel code.

Code:

#!/bin/csh -f

# start UVLayout
uvlayout -debug -plugin,Edit pack.obj &

# create command file
cat > pack-cmd << EOF
run UVLayout|Pack|Pack All
run UVLayout|Plugin|Save
EOF

# process files
foreach mesh ( $* )
echo "Sending $mesh ..."
cp $mesh pack.obj
cp pack-cmd pack.cmd
while ( ! -e pack.out )
        echo "Waiting for result ..."
        sleep 1
end
echo "Saving result ..."
mv pack.out done-$mesh
echo "Waiting for UVLayout ..."
sleep 6
end

# kill UVLayout
rm pack-cmd
echo exit > pack.cmd




Phil
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hnzhang



Posts: 7
Joined: 08 Oct 2010

PostPosted: Tue Oct 19, 2010 1:23 pm    Post subject: Reply with quote

Thanks for your test, Phil

Coincidently, I did the same, per lightmap group,
--uvlayout is launched as plugin
--geometries are save to obj file
--commands are saved to cmd file
--wait until output file is writable(means uvlayout finishes its job)
--send exit command
--wait for 8 seconds

This works perfectly.

Thanks again.
Back to top
View user's profile Send private message
dela



Posts: 20
Joined: 06 Dec 2017

PostPosted: Tue Dec 12, 2017 7:46 am    Post subject: Reply with quote

What is actually the use for setting SUBD or Poly after the file is loaded. These settings dont seem to be used on the next load. Why you want to set them after file is loaded i dont get.

The command drop does work directly.

Still figuring out OSX how the get '-plugin, SUBD, edit' to work. I think this just wont work on OSX.

this is part if loadind code, when i add the
Code:
'-plugin, SUBD, edit'
part before the file. I do get a load panel but nothing is set. When i add the code after the file. i See error in console, im using blender on OSX for this.

This works but no commands are send
Code:
''/Applications/headus-UVLayout-'+versiononUVL+'.app  -uvlayout-plugin', path+file_Name'


If i leave spaces out i get this error;
Code:
uvlayoutP: Need to define plugin transfer file in args.


Using this results opening app in regular mode.
Code:
''/Applications/headus-UVLayout-'+versiononUVL+'.app'


Sending the command to *cmd file after OBJ is created also work, though i dont see the point of setting the Type after file is loaded. Setting it doesnt change anything, the drop command does work as do the others. Sometimes however the window closes and only main panel is visible. I need to redo the export then???
Back to top
View user's profile Send private message
headus
Site Admin


Posts: 2871
Joined: 24 Mar 2005
Location: Perth, Australia

PostPosted: Thu Dec 14, 2017 4:24 pm    Post subject: Reply with quote

"Sending the command to *cmd file after OBJ is created also work, though i dont see the point of setting the Type after file is loaded"

You are correct, so you need to create the CMD file *before* writing out the OBJ file. UVLayout is looking for the OBJ, so when it sees that, it looks for the CMD to apply the settings when the OBJ is loaded.

And generally speaking, working with the CMD file is easier than adding the options to the command line. As you've discovered, knowing where and when to put spaces and quotes etc is complicated because of the multiple levels of execution (i.e. plug runs script which runs application).

Phil
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dela



Posts: 20
Joined: 06 Dec 2017

PostPosted: Thu Dec 14, 2017 5:01 pm    Post subject: Reply with quote

BUt i tried adding the .cmd file and it does set it to say SUBD but it doesnt apply it to that model when it loads it during plugin send.

Why dont the arguments work on OSX or how do they need to be implemented?
Back to top
View user's profile Send private message
headus
Site Admin


Posts: 2871
Joined: 24 Mar 2005
Location: Perth, Australia

PostPosted: Thu Dec 14, 2017 5:21 pm    Post subject: Reply with quote

Are you using you own plugin? if you're using someone else's, could it be writing its own CMD file, overriding whatever you put in your own?

Anyway, I just checked the code, and it looks like a SET file will do the same job, and maybe will work better in this case. So as with the CMD file, just write "poly" or "subd" to the plugin file with a ".set" extension.

Phil
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dela



Posts: 20
Joined: 06 Dec 2017

PostPosted: Thu Dec 14, 2017 5:25 pm    Post subject: Reply with quote

Can this *.set file have multiple commands?

what i like about the arguments is that you can pass all along. With the *.cmd file you can set UV to edit or new.

The way the code is setup is by writing a obj file, this then get read by uvlayout. That change the file to *.keep and at the moment it sends it. The plugin writes a exit in a *.cmd file

I tried the other commands like pack etc and they work as well before or after the command. But uv edit and new doesnt work then.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group