Friday, March 30, 2007

Solid gold

Ok I haven't posted in too long and this one is going to be really short, but I have some really fun plans along the lines of a function key parser, editor, etc. that will really push into the python dictionary data type.

For now though let me pass along huge kudos to the team at Cardinal. I often have thoughts of the guys slaving away in the salt mines at the Vr Development lab. Poorly used and un-appreciated for the efforts that spring forth. However in the latest patch versions (usual disclaimers about beta software, or anything that isn't in official full release, blah..blah..) there are a couple of nuggets of pure gold. One is attaching in fly-line, granted this doesn't have anything to do with python, but along with things like all the different snap options, overloading (I better stop before I get carried away) attaching a fly-line is one of those things that will make me pause and think "wow, I love this stuff". The python related gold nugget is Ws.IdEnt() which allows the user to just start a generic ID routine then select anything on the screen, or cycle through entity types. This is the same ID that is used for fasdel and others like it. Check it out on the python help pages, it is absolutely too cool.

I'll also toss in a little utility that I use to save the current layer display status. Disclaimer here is that it only works with 3.2 and above because before that PyVrLayer had it's own module. It could be modified to work like that, but this version doesn't.

Layer = VrLayer ()
Gui=PyVrGui()
# Initialize Vr objects to be used.
parfile=open('c:/vr/hostdir/save_lay_stat.par','w')
# Open a parameter file to save the layer status in. 'w' is write mode.
for laynum in range(1000):
..parfile.write("%d %d\n"%(laynum,Layer.Stat(laynum)))
Gui.DspMsg0('Layer state saved')
# I'm only going to save the status of the first 1000 layers, I rarely use any others.
# Then write the Stat() or current status along with the layer number.
parfile.close()
# Always close files when done. Python is smart this way, but it's good practice.



No comments:

For anyone interested in trying VrPython for the first time or if you are early in the game, I suggest going to the earliest posts and working forward. I use VrPython every day for many wonderful things, needless to say it will change and could potentially damage a file. Any risk associated with using VrPython or any code or scripts mentioned here lies solely with the end user.

The "Personal VrPython page" in the link section will contain many code examples and an organized table of contents to this blog in a fairly un-attractive (for now) form.