[Closed] are grid views available through maxscript?
Hi all,
I was trying to set the views for grids but the only one I found is top view. Am I missing something in the reference or is it not possible?
If you right click on the viewport’s name and go to grid you have access to all but nothing is displayed in the listener when changing…
Any ideas?
Thanks!
Anton
viewport.setGridVisibility <viewport> <state>
<viewport> is the viewport number, and <state> is true or false.
Just type viewport into the listner and you’ll see the structure functions available.
Stev
Thanks stev but I wasn’t looking for that. I wasn’t clear in my previuous post!
What I am looking for is to set the view in a viewport to say to “front”, “back”, “left”, “right” etc. but for the active grid not for the home grid. The only one that i found is the top view by doing this:
viewport.[font=Courier New][b]setType #view_grid[/b][/font]
And I was wondering if it is possible to set the others as well!
Thanks,
Anton
What about these?
viewport.setType #view_Front
viewport.setType #view_Back
viewport.setType #view_Left
viewport.setType #view_Right
viewport.setType #view_Bottom
viewport.setType #view_Top
$viewport.setgridvisibility = bool (true or false )
this will make the grid visible for the selected viewport.
stev, those are for the home grid. But if you have a custom grid then you cannot do it like that!
Try creating a custom grid and make it active. Then try those commands and the’ll give you the views for the home grid!
Ah, now I know exactly what you mean. I’m not sure if you can do that. Sorry.
Stev
viewport.setType operates on the current active viewport. To set all viewports to grid, you could try:
for v = 1 to viewport.numViews do
(
viewport.activeViewport = v
viewport.setType #view_grid
)
Martijn
Argh! forget the above… Sorry I didn’t read your question properly either…
I think that these grid types are indeed not accessible through maxscript… I guess it should be relatively easy for a C programmer to write a maxscript extension for this though. Try posting your question on the Autodesk forums, maybe an SDK expert chimes in.
Cheers,
Martijn
Thanks for the tip Martjin. I figured a workaround and probably tonight I’ll have the time to finalize it.
There is a set of commands for viewport that allow you to set the transform matrix for the view and if you assign it the inverse of the transform matrix of the agtive grid it will give you the top view for that grid. The rest is pretty easy if you have some knowledge of how to rotate the TM of the grid to give you all the other views.
Here is the line to get the topview of the active grid:
viewport.setTM (inverse(activegrid.transform))
Yeah that’s what I came up with as well. Although it’s not exactly the same thing as using the viewport menu it does align the view to the grid.
I had some spare time so I wrote a simple macroscript. Right now it shows a popupmenu with the view types, but feel free to rip out the function that does the actual work, and adjust it to your needs.
Cheers,
Martijn