ScriptSpot

Forum topic · General Scripting

how to change the work plane

By Bones · 2011-12-10

Description

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 (6)

Bones · 2011-12-12

thx miauu :D
it's working now :D

miauu · 2011-12-12

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 · 2011-12-12

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

miauu · 2011-12-10

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 · 2011-12-10

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
		)

Use activeGrid

miauu · 2011-12-10


-- $ is the selected object
activeGrid = $

Use
activeGrid = undefine
to activate the Home Grid