Start a new topic

Rotate Plane at Center

I need to turn 1000s of billboard trees into cross style trees so I need a script that will rotate the plane at the center point of the plane, 90 degrees in z axis. generally we do this as externals for the tree, but .. this is an old database that someone setup like this years ago.

1 person has this problem

Ok I got a basic script working for it: db = mgGetCurrentDb() selectList = mgGetSelectList (db) num = mgGetRecListCount (selectList) for i in range (0, num): rec,m = mgGetNextRecInList (selectList) ok, bounds = mgGetBounds (rec) center = mgCoord3dDivide (mgCoord3dAdd (bounds.max, bounds.min), 2.0) mgDeselectAll(db) mgSelectOne (rec) paramBlock = mgGetParamBlock ("Rotate About Point") mgParamSetDouble3 (paramBlock, "Center Point", center.x, center.y, center.z) mgParamSetDouble (paramBlock, "Angle", 90) mgExecute ("Rotate About Point", paramBlock) despite the fact that I dont really understand this language. But theres another issue. all of the tree planes are angled. someone though it was a good idea to angle them all in the Y axis so the top of the tree would have been farther from the camera than the bottom when it was using the facing option. So, I need to be able to align the vertices in the Y axis. Is this possible? I haven't found anything online on the API and the align function. Thanks, Joe

Hi,


I think I can help you with your problem, but first let me commend you on how far you have gotten on your own!  Ok, for your problem, the easiest way would be use our Flatten Y tool in the script. You should be able to simply call it before doing your rotate about point. I see your script is also missing one other feature. If you need to turn these into cross-hatch, you will also need to duplicate the non-rotated, post flattened quad. This should give you the cross hatches you want.


I took your script and added what I just described.


 

db = mgGetCurrentDb() 
selectList = mgGetSelectList (db) 

num = mgGetRecListCount (selectList) 
for i in range (0, num): 
	rec,m = mgGetNextRecInList (selectList) 
	ok, bounds = mgGetBounds (rec) 
	center = mgCoord3dDivide (mgCoord3dAdd (bounds.max, bounds.min), 2.0) 
	mgDeselectAll(db) 
	mgSelectOne (rec) 
	
	paramBlock = mgGetParamBlock ("Flatten Y")
	mgParamSetInteger (paramBlock, "Flatten to", 0)
	mgParamSetDouble (paramBlock, "Percent", 100)
	mgExecute ("Flatten Y", paramBlock)

	newRec = mgDuplicate (rec)
	mgInsert(rec, newRec)
	
	paramBlock = mgGetParamBlock ("Rotate About Point") 
	mgParamSetDouble3 (paramBlock, "Center Point", center.x, center.y, center.z) 
	mgParamSetDouble (paramBlock, "Angle", 90) 
	mgExecute ("Rotate About Point", paramBlock) 

 



1 person likes this
Login to post a comment