Aces High Bulletin Board

General Forums => Terrain Editor => Topic started by: Xjazz on September 26, 2007, 02:41:19 PM

Title: OE: object batch convert?
Post by: Xjazz on September 26, 2007, 02:41:19 PM
Hi

Has anybody tried any commercial desktop macro softwares for the task?

I  am trying to do a same function with python:

import SendKeys
SendKeys.SendKeys("""
    %^§
    [pause=15]
    %f
    c
    +{TAB}
    {END}
    ~
    [pause=5]
    %f
    e
""")


This script open the OE with my assigned windows shortcut.
Then it open the Convert dialog and select the first .ac file from the list and hit enter.
Close to OE.

Still the loop and 1-by-1 file selection needs to solve.
Title: OE: object batch convert?
Post by: Xjazz on October 01, 2007, 03:04:56 PM
Here we go


This script will convert all .ac files from HTC/ah2editor/ahiiterr/Tiles/ folder.


# The Batch convert tool for the Aces High 2 Object-Editor(OE) by Xjazz
# Script requires the python 2.4+ and the SendKeys module installation
# The SendKeys module is available at:
# [url]http://www.rutherfurd.net/python/sendkeys/index.html[/url]
#
# This script assumes, your OE windows short-cut is CRTL+ALT+1
# Place script to the ah2editor folder and run it by double clicking it
#
# Ver. 0.2beta / 01.10.2007

import os, SendKeys

# You must set the path to the Tiles-folder
path = 'c:/Program Files/HTC/ah2editor/ahiiterr/Tiles/'

def getFiles(path):
    ac_names = []
    arqs = os.listdir(path)
    for a in arqs:
        if a.endswith('.ac'):
        ac_names.append(a)

          # User can adjust the PAUSE times at will. YMMV
        SendKeys.SendKeys("{PAUSE 1}%^1{PAUSE 5}%fc"+a+"~{PAUSE 2}%fe")
  return ac_names

getFiles(path)

# 'You must delete the "cache" folder before you restart the OE'


No error handling to mention. Make sure you have proper texture files copied to the Tiles folder.
Title: OE: object batch convert?
Post by: croduh on October 02, 2007, 01:54:17 AM
Will have to try that, nice work.
Title: OE: object batch convert?
Post by: Xjazz on October 04, 2007, 02:03:26 PM
Quote
Originally posted by croduh
Will have to try that, nice work.


S! Croduh,

Let me know how it is working for you. All ideas are welcome.

(Mumbling by myself:Lots of views but only one feedback... Maybe this has something to do with the windmills)

....

Aaanyhow

I'm doing now a test  version coding for the Batch_Checking script, which will do a pre-convert checking for files in Tiles folder as far as possible:

-  Check if all ac. file assigned .bmp texture files are available in Tiles folder.
- Check if *.bmp textures are in index mode and  *_a.bmp alpha layers are in grayscale mode.
- If *_.txt file is present, the user defined GLOBAL alpha channel value is checked from target *.bmp.
- If sub-object has a 'StencilAlpha' flag, the texture related _a.txt file checked.

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

The future visions

Possible options:
- The automatic texture mode conversion and _a.txt file creation with valid alpha channel data (with PIL)
- The converted *.shp & *.htx file are copied to the target project texsrc folder.
- The whole project folder is zip back-upped before any copy-to actions.
- The TE is launched to the target project (sendkeys)
Title: OE: object batch convert?
Post by: Easyscor on October 04, 2007, 02:15:17 PM
Clearly you know what you're doing but it's all :noid

You're way too far ahead of me to know what's going on but it's still interesting to read. Glad you finally found a soul mate.:aok
Title: OE: object batch convert?
Post by: Ghastly on October 04, 2007, 02:59:54 PM
Quote
Lots of views but only one feedback


I read everything in this forum, even when  it's way way way "out there" from the level I'm at, and far removed from what I'm doing at this time.

Someday, when I need it, I'll go - "wait a minute, didn't someone post ... ?????"

Title: OE: object batch convert?
Post by: Xjazz on October 04, 2007, 03:29:13 PM
(some bites are working better than brand x brand bites...) :D

The manager level message is: I invent something, which will cut-down the routine work load in long run'.

I bet some people didn't take a time to adjust several object property  parameters at once...

--------

Somehow it is sad,...After all these years, it takes my kind of self learned Sunday code quack to do a OE-TE related utile, which will cut-down the custom object-terrain maker workload.

I was cooking my idea now & then several months. The HTC could do same thing since OE T0 with in hour or quarter.

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

But... If there's simple no need for the batch check / convert tool. Why I typing here?!
Title: OE: object batch convert?
Post by: NHawk on October 04, 2007, 03:41:42 PM
Quote
Originally posted by Xjazz
....(Mumbling by myself:Lots of views but only one feedback... Maybe this has something to do with the windmills)....
I try to read every post in this forum. Sometimes twice! So I inflate the view count on many messages. :)
Title: OE: object batch convert?
Post by: Xjazz on October 04, 2007, 03:54:47 PM
Quote
Originally posted by NHawk
I try to read every post in this forum. Sometimes twice! So I inflate the view count on many messages. :)


It was YOU?! Why you little!!!! :D

-----

Making a OE-TE things a manually in old fashion way don't make you any better than rest of us... The progress is here.
Title: OE: object batch convert?
Post by: croduh on October 05, 2007, 02:46:35 AM
Well first it seems i have to get my self that phyton and send keys...
Title: OE: object batch convert?
Post by: Xjazz on October 05, 2007, 01:47:02 PM
Quote
Originally posted by croduh
Well first it seems i have to get my self that phyton and send keys...


Yes, you need to install python before you can run *.py / *.pyc files.

Python 2.51
http://python.org/download/

SendKeys module in needed with my script
http://www.rutherfurd.net/python/sendkeys/index.html

but

I'm working now with stand alone windows exe version :)
Title: OE: object batch convert?
Post by: BlauK on October 06, 2007, 05:43:08 AM
It is so stupid that one cannot just simply select several files at the same time in  the OE's convert dialog.
Very good heads up Xjazz :aok Gotta check this out next time I have several objects under work.
Title: OE: object batch convert?
Post by: Xjazz on October 07, 2007, 07:50:56 AM
Hi

Here is a latest batch convert script version.
http://www.warezhouze.1g.fi/Here/Blender3d/AH_scripts/OE_batch_convert_py_v04b.zip

The zip file contains the script and settings files. Unzip them to your ?:/Program Files/HTC/ah2editor/ahiiterr/Tiles/ folder.

The 'installation':
- Create the OE shortcut with CTRL+ALT+1 shortcut key(default). OR define your own.
- Update the 'oe_bs.txt' settings file content with proper path and OE shortcut data.
- Create the Batch_Convert_py2exe_04b.py shortcut,with minimized 'Run' window, to the desktop.

Run the script:
- COPY .ac files with all needed textures and related files to the //Tiles/ folder
- Close all other applications and start the script with desktop shortcut.
- Don't open other applications while script is running.
- The batch convert is  finished when the script Taskbar window disappear.

This .py file is a stand-alone windows .exe candidate.
Title: OE: object batch convert?
Post by: croduh on October 07, 2007, 08:10:57 AM
Don't understand some parts of your instructions:

Where do i create the OE shortcut?On desktop?In the tiles folder?
Sorry, but what you wrote is a bit confusing:D
Title: OE: object batch convert?
Post by: Xjazz on October 07, 2007, 02:37:51 PM
Quote
Originally posted by croduh
Don't understand some parts of your instructions:

Where do i create the OE shortcut?On desktop?In the tiles folder?
Sorry, but what you wrote is a bit confusing:D


I write it in hurry....

So

1. Create a ahobedit.exe (OE) shortcut to the ah2editor folder.
(http://www.warezhouze.1g.fi/Here/Blender3d/pics/Batch_script_inst/1_OE_shortcuti.jpg)


2. Create a shortcut key (ctrl+alt+1) for OE shortcut in shortcut properties.
(http://www.warezhouze.1g.fi/Here/Blender3d/pics/Batch_script_inst/2_OE_shortcut_keyi.jpg)


3. Create a shortcut for the Batch_Convert_py2exe_04b.py script to the Tiles folder.
(http://www.warezhouze.1g.fi/Here/Blender3d/pics/Batch_script_inst/3_scrpit_shortcuti.jpg)


4. A. Drag and drop the Batch_Convert_py2exe_04b.py shortcut to the Taskbar or to the desk top.
4. B. Set Run-mode to the 'Minimized'.
(http://www.warezhouze.1g.fi/Here/Blender3d/pics/Batch_script_inst/4_script_move_propi.jpg)

Ok? :)
Title: OE: object batch convert?
Post by: USRanger on October 07, 2007, 09:50:17 PM
(http://img233.imageshack.us/img233/5093/duncedh5.gif) (http://imageshack.us)
Title: OE: object batch convert?
Post by: Easyscor on October 08, 2007, 04:08:58 AM
Just for clarification, are you converting a large batch of .ac files into separate .shp files and dropping them into the texsrc folder all at once, or have you worked out a way to combine several .ac files together?
Title: OE: object batch convert?
Post by: Xjazz on October 08, 2007, 12:57:14 PM
Quote
Originally posted by Easyscor
Just for clarification, are you converting a large batch of .ac files into separate .shp files

Yes, this is what script is doing currently.

Quote
Originally posted by Easyscor
and dropping them into the texsrc folder all at once

No, but it's possible to code a user dialog about target texsrc-folder, to where script will copy just converted *.shp & *.htx files. User just need to delete the cache folder before open the TE.

Quote
Originally posted by Easyscor
or have you worked out a way to combine several .ac files together?

I think, it's possible to do.
I already made a script which allow user to reorganize hierarchy tree and edit the properties inside of the .ac file without AC3D program.
http://forums.hitechcreations.com/forums/showthread.php?s=&threadid=192932&highlight=python
Title: OE: object batch convert?
Post by: Easyscor on October 08, 2007, 01:52:19 PM
Thanks
Title: OE: object batch convert?
Post by: BlauK on October 08, 2007, 04:24:30 PM
Quote
Originally posted by Xjazz

No, but it's possible to code a user dialog about target texsrc-folder, to where script will copy just converted *.shp & *.htx files. User just need to delete the cache folder before open the TE.


I have actually always been using a batch file for copying the newly created res file to texsrc and deleting the cache at the same time. It is very simple.
Title: OE: object batch convert?
Post by: Easyscor on October 08, 2007, 06:11:37 PM
Here all this time I thought both of you were from Finland.  I know now that can't be true because the Finns all meet in a big conference hall and talk while they work on terrains and drink lots of alcohol. :lol
Title: The pre-convert batch checking script(beta)
Post by: Xjazz on October 15, 2007, 03:40:54 PM
Hi

Here is a pre-convert batch checking script(beta):
http://www.warezhouze.1g.fi/Here/Blender3d/AH_scripts/Batch_check_ob1.zip

The script is checking following issues:
- All .ac file assigned textures are present in same folder with .ac file.
- The *.bmp and *_a.bmp textures have correct modes: index / gray scale.
- The *_a.txt file index value match with target texture index value of  R255G0B255 color (ah default alpha ch.).

Requirements:
python 2.5+
Python Imaging Library 1.1.6 for Python 2.5 (windows only) from
http://www.pythonware.com/products/pil/

Installation:
The zip file need to unzip to the AHedit Tiles folder.

If you already have the Batch_convert_04b.py script, then you don't need to unzip the 'oe_bc.txt' file.

The 'oe.bc.txt' must contain correct path to the /Tiles/ folder.


Run it:
Start the python, open the 'Batch_check_beta.py' file and execute it  with F5 key.
The script will list checked .ac files and possible error message to the python shell window.

Report
(http://www.warezhouze.1g.fi/Here/Blender3d/pics/Batch_Check_report.jpg)
Title: OE: object batch convert?
Post by: BlauK on October 15, 2007, 04:24:43 PM
XJazz,
how would the program now the correct *_a.txt value?
AFAIK, it can be anything between 0 and 255 for each and every file.
Title: OE: object batch convert?
Post by: Xjazz on October 16, 2007, 01:10:37 PM
Quote
Originally posted by BlauK
XJazz,
how would the program now the correct *_a.txt value?
AFAIK, it can be anything between 0 and 255 for each and every file.


It's possible if we have .bmp name and intent alpha channel color value.

If we use a global alpha channel color value, like I do in Batch_check script, then possible solutions could be:
- User creates empty (texture file name)_a.txt files and script will write the index data to them.
- If sub-object texture has a 'StencilAlpha=*' flag, the script will create the (texture file name)_a.txt file with index data.

Untested idea:
- the .ac file sub-object has in property field a intent alpha channel color value for the script in certain format, like r255g0b255.

Blauk
If you have a idea about functional solution for you, let know about it. I like to take a shot and try to code it.
Title: OE: object batch convert?
Post by: BlauK on October 16, 2007, 03:17:05 PM
XJazz,
.. u going too fast for me being able to follow :)

What I meant is that when I make some texture in PhotoShop and use some color which I intend to present the transparent color, I have no control on which position that color will take in the color map when I covert the texture to indexed color. Never even tried to change the color map to get a certain value for it. Dunno whether it is possible.
Sometimes it is 0 or 1, sometimes around 2-4, sometimes around 16. I just check its position from the color map and type the number to the *_a.txt file.
Title: OE: object batch convert?
Post by: Xjazz on October 17, 2007, 11:19:42 AM
Quote
Originally posted by BlauK
XJazz,
.. u going too fast for me being able to follow :)

What I meant is that when I make some texture in PhotoShop and use some color which I intend to present the transparent color, I have no control on which position that color will take in the color map when I covert the texture to indexed color. Never even tried to change the color map to get a certain value for it. Dunno whether it is possible.
Sometimes it is 0 or 1, sometimes around 2-4, sometimes around 16. I just check its position from the color map and type the number to the *_a.txt file.


Hee hee

Dump that PS and start to use GIMP.

http://www.warezhouze.1g.fi/Here/AH/pics/GIMP_index.jpg

I can assign any color(256) to any index.
Title: OE: object batch convert?
Post by: BlauK on October 17, 2007, 12:08:53 PM
The point was that there has been no reason so far to force the transparent color to some certain number ;)

If this error checking would be the only reason, I don't think I would change my work process just for that. There is enough error checking for that issue when one sees the actual object with or without the odd colored areas.
Title: OE: object batch convert?
Post by: Xjazz on October 17, 2007, 02:37:54 PM
Okey...

I misunderstand you. I though, somehow, you want to see a forced color index. I was wondering why :D


Currently the checking script is assuming the user ONLY use a pink (r255 g0 b255) as alpha channel color I.E. global alpha channel color. This will make the automated *_a.txt value checking & fixing possible. Also the automated *_a.txt file creation is possible for the 'StencilAlpha' flagged textures.

The main reason for the checking is to ensure error free batch convert run. Checking also saves from the nasty dead shape alpha channel/layer texture appearing surprises.


There is enough error checking for that issue when one sees the actual object with or without the odd colored areas.

My wild guess
Two different textures in different maps with same name. Last game cached texture appear in two maps... Maybe.
Title: OE: object batch convert?
Post by: BlauK on October 17, 2007, 03:30:18 PM
So you can somehow detect that "pink" RGB value from teh BMP files? Or will you always have it in a certain color index number... thus checking only what number is in the txt file?
Title: OE: object batch convert?
Post by: Xjazz on October 20, 2007, 04:51:08 PM
Hi

Here is the latest Batch_check
http://www.warezhouze.1g.fi/Here/Blender3d/AH_scripts/Batch_check_0b4.zip

The requirements, installation and execution are same as before*.

Features:
- Missing  .bmp texture file notifying.
- Wrong .bmp texture file color mode notifying.**
- Automated *_a.bmp alpha layer texture file color mode fixing.
- Automated *_a.txt file alpha channel R255 G0 B255 index value fixing.
- Automated *_a.txt file creation with alpha channel R255 G0 B255 index value for the 'StencilAlpha' flagged textures.
- Report to the python shell and to the 'BATCH_CHECK_REPORT.txt' text file about the checked .ac files and possible errors.

* You create the short-cut to the script if you don't want to execute script from python (F5) and read the report from python shell.
* * The PIL RGB to Index conversion don't work too well yet and that's why I left it out. User must take care of this task.