how to change the work plane

Hi

I'm working on a little Script which sets the viewport rotation to the left/right/bottom/top view. similar to ZBrush where you can snap the viewport to left/right etc.

My problem is, that I have to change the constuction plane. Otherwise it's not possible to create any Objects like Boxes etc.
But I can't find the command to do that.

Is there a command to do that?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Bones's picture

thx miauu :D it's working now

thx miauu :D
it's working now :D

miauu's picture

Create a grid helper(or

Create a grid helper(or point) and use the grid transform as the constr. plane

 
-- create grid helper and set its position 
grid name:"tempConstrPlane" position:[10,10,12]
 -- use this grid as constr. plane 
activeGrid = $tempConstrPlane 

Visit THIS link and watch the video. Is this is what you want?

Bones's picture

I don't know how to change

I don't know how to change the constr. plane :s That is problem :(

miauu's picture

You rotate the viewport, but

You rotate the viewport, but the constr. plane is the Home grid - you not change it. Why? Objects are created according to constr. plane, not viewport rotation.

Bones's picture

Thanks for your answer.

Thanks for your answer. Unfortunately this is not working ... or I do something wrong :(

Maybe you can test my code.
To use it, go into the perspective view and run the code. it will go into the orthographic view and snap the viewport (camera rotation).
Then try to create a plane. It wont work because the constructionplane is still the constructionplane from the perspective view :( (it will work when the camera snaps to the bottom/top view)

(
			if cr_ViewportPos == undefined then
				global cr_ViewportPos
 
			if cr_ViewportPos != (viewport.getTM()).rotationpart then
			(
				local tempV = (viewport.getTM())
				local tempVA = #(tempV.row1, tempV.row2, tempV.row3)
 
				local masterArray = #([0,0,0],[0,0,0],[0,0,0])
 
				for i = 1 to 3 do	
				(
					id = 0
					tValue = 0
					for r = 1 to 3 do	
					(
						if abs tempVA[r][i] > tValue then
						(
							id = r
							tValue = abs tempVA[r][i]
						)
					)
			-- 			print id
					if tempVA[id][i] > 0 then
						masterArray[id][i] = 1
					else
						masterArray[id][i] = -1
				)
				for i = 1 to 3 do	
				(
					local temp = 0
					for o = 1 to 3 do	
					(
						temp = abs masterArray[i][1] + abs masterArray[i][2] + abs masterArray[i][3]
					)
					if abs temp < 1 then
						masterArray = #([1,0,0],[0,0,-1],[0,1,0])
				)
				viewport.setTM (matrix3 masterArray[1] masterArray[2] masterArray[3] tempV.row4)
				actionMan.executeAction 0 "310"  -- Tools: Zoom Extents Selected
 
				if viewport.IsPerspView() then
					actionMan.executeAction 0 "40183"  -- Views: Orthographic User View
			) else (
				print "loool"
				actionMan.executeAction 0 "40182" -- perspective view
			)
			cr_ViewportPos = (viewport.getTM()).rotationpart
		)
miauu's picture

Use activeGrid

-- $ is the selected object
activeGrid = $

Use
activeGrid = undefine
to activate the Home Grid

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.