The Make Geometry tool converts instances into non-instance copies of the instance, and it removes transforms after it applies the transforms to the vertices. You are writing the script/code here, so what would you like to accomplish? If all you really want to do is run make geometry on many different files, the easiest way would be to write a script that opens the files you want to process one at a time, then sends the windows commands: alt+d+m+enter. (this will launch the make geometry command and ok the dialog.)
However this is sort of a hack, and it is not very robust. It would be better to write your own script to process the geometry, then convert it to what you want. This way when you need to modify the conversion slightly (to include things make geometry doesn't...) then it will be a simple task of modifying the script.
...it removes transforms after it applies the transforms to the vertices...
This is exactly the part I'm after.
As part of a larger script, I'm batch processing many individual flt's, each of which contains one object. My aim is to resize/rescale the object and then remove the transform. Sometimes the objects may already have some/many transforms applied to them, so in an effort to "clean up" the models I wanted to "collapse" the transforms down - I'm used to using "Make Geometry" in Creator to do this manually.
So I guess now my question is - do I want to be doing the following:
- walk through the hierarchy and if a record is an fltObject, use mgGetMatrix to save the Object transform to a temp variable
- remove the transform (/Matrix?) from the object
- carry on 'walking', and if record type is a vertex
- apply the saved Matrix to each vertex using mgSetMatrix
Sorry if that all sounds a bit amateurish or like I don't know what I'm doing - it's just a bit confusing
Thanks for the help by the way
Thanks for the description of what you wanted. To get you started, I have attached a short script that walks over the vertices in a file, gets the cumulative matrix, transforms the vertices by that matrix, then removes the xforms. You could extend this script to run on a set of files rather easily. You could also really easily translate this script into OpenFlight API calls if you would rather work in c++ code.
I hope this helps:
def walkDbPre (db, parent, rec, i):
code = mgGetCode (rec)
print code
print mgGetName(rec)
if ( code == fltVertex ):
matrix = mgWalkGetMatrix (i)
ok, x,y,z =mgGetVtxCoord (rec)
coord = mgMakeCoord3d (x,y,z)
coord = mgCoord3dTransform (matrix,coord)
mgSetVtxCoord (rec, coord.x, coord.y, coord.z)
return MG_TRUE
def walkDbPost (db, parent, rec, i):while ( mgHasXform (rec) ):
xform = mgGetXform(rec)
mgDetach (xform)
mgDelete (xform)
return MG_TRUE
db = mgGetCurrentDb ()
mgWalk (db, walkDbPre, walkDbPost, None, MWALK_VERTEX|MWALK_MATRIXSTACK)print "Finished"
Wow, that's great - easy to understand what's going on and why.
Many thanks, that helped so much :)
That was a great information...So easy to learned..Thanks for sharing it.
[URL=http://dossierdesurendettement.net/rachat-de-credit-surendettement]Rachat de credit surendettement[/URL]
Craig
I'm trying to copy the "Make Geometry" functionality that you get in Creator, using the Openflight API and Python. I stumbled across this post which did point in the right direction, but I'm struggling to understand exactly what needs doing.
Could someone maybe post the basics of how "Make Geometry" works and what I would need to do to achieve the same thing with the Openflight API?