<< Back to Warzone Classic Forum   Search

Posts 1 - 5 of 5   
Automatically ids giving: 7/16/2010 18:59:16


rashaz
Level 56
Report
Anyone have an idea how to automate giving ids to the objects in the Inkscape? Macro or something? It would be very helpful.
Automatically ids giving: 7/17/2010 16:05:33


Matma Rex 
Level 12
Report
I use a little Ruby script:

r=File.open('read from this file.svg').read
r.gsub!('id="path', 'id="Territory_')
File.open('write to this file.svg', 'w').write r


Copy that, save as something.rb, change the filenames, copy to directory containing the file and run. You must have Ruby interpreter installed (any version) - it's free. You can get it here: http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe (25 MB).


It only works if objects already have "path9999"-format ids - but it seems they always have. Also, it will convert every single path to territory - you might have to change some ids back.

Hope you like it :D
Automatically ids giving: 7/17/2010 16:30:05


rashaz
Level 56
Report
Thanks, I'll try this when I'll be at home ;] Hm, but there can be problem with ids becouse in the file on which I'm working objects are named by 6 random numbers. Is there any possibility to use something which works like "*" in *.svg? You know, for example 'id="*' and it would search for phrase id= with any content between those inverted commas.
Automatically ids giving: 7/17/2010 21:58:58


Matma Rex 
Level 12
Report
The script I posted doesn't change the numbers at all - "path4567" becomes "Territory_4567", and actually "pathJamesBond" would become "Territory_JamesBond" - that part is not touched at all.

And Warlight doesn't care if the territory numbers start from 1 and go on (2, 3, ...) - it accepts anything that is a number.



But, if you want it to be tidier, use this:

r=File.open('read from this file.svg').read
i=1
while r.index(/id="path\d+"/)
r.sub!(/id="path\d+"/, 'id="Territory_'+i.to_s+'"')
i+=1
end
File.open('write to this file.svg', 'w').write r



All "Territory_" ids will have consecutive numbers. This also doesn't change any id that doesn't contain a number.
Automatically ids giving: 7/18/2010 12:41:44


rashaz
Level 56
Report
Thanks, that script is great ^^ It'll save a lot of time ;]
Posts 1 - 5 of 5