Notifications
Clear all

[Closed] Need some advice – wich axis XY,XZ,YZ is "active"

How to know wich axis – XY, XZ, YZ in the scene(of the world axis gizmo) is “active”. My englihs is not very good, so see the image:

12 Replies

there is no an easy way to get it. but i think you overcomplicated the task. why do you need it?

I want to show one object1 when XY become active and to hide object2. Then I want to show object 4 when YZ become active and hide object2. When XY become active again I want to show object1 and hide object4.

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

as i understood you want to hide/show only unselected objects?
is it some sort of a GUIDANCE where to go/move?

(@denist)
Joined: 11 months ago

Posts: 0

as i said you can’t get what MAX shows, but you can guess. you have everything for that: the mouse position, the current selection, the coordinate system center, the transform gizmo size…
it’s not a big deal to get what max has to show.

toolmode.axisConstraints

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s too simple to be true

@halloween, toolmode.axisConstraints give me the Xy,Yz or Xz axis that user define by clicking on the transform gizmo.
@denisT, yes, I want to hide/show only unselected objects
I was thinking to use getViewTM() and try to find the “active” viewport orientation, but…no success for now..

Indeed. Good luck

help ,
How to calculate many box ,total length, total width, total height Respectively?
I write a simple code, but have message,

if selection.count > 0 do
p = #()
p = for i in selection where isGroupMember i == false collect i

for n = 2 to ( p.count – 1 ) do
(
moo = (p[n].max -p[n].min).x

)

how to Cumulative?

I made ​​a mistake
Please moderator delete

Miauu – I’m by no means a great scripter but I managed to get something like this working for a workplane alignment script I made a few months ago. See if this code helps you out.


(
	workplanePos = try($workplane.pos)catch([0,0,0])
	gridObjs = for obj in helpers where classof obj == grid collect obj
	delete gridObjs
	workplane = grid length:128 width:128 grid:8
	workplane.name = "workplane"
	
	fn getViewAxis =
	(
		local coordSysTM = orthogonalize(inverse(viewport.getTM()))
		global getViewDir = coordSysTM.row3
		local viewDirValues = #(abs(getViewDir.x), abs(getViewDir.y), abs(getViewDir.z))
		local viewFindFurthest = findItem viewDirValues (amax viewDirValues)
		local viewDirAxis = case viewFindFurthest of ( 1:"x"; 2:"y"; 3:"z")
		local viewDirAxisValue = execute("getViewDir." + viewDirAxis)
		
		viewDirAxis = case viewDirAxisValue < 0 of (true:-viewFindFurthest; false: viewFindFurthest)
		return viewDirAxis
	)
	
	fn updateWorkplane =
	(
		try
		(
			workplanePos = workplane.pos
			case getViewAxis() of
			(
				1:
				(
					workplane.transform = matrixFromNormal [1,0,0]
				)
				
				2:
				(
					workplane.transform = matrixFromNormal [0,1,0]
				)
				
				3:
				(
					workplane.transform = matrixFromNormal [0,0,1]
				)
				
				(-1):
				(
					workplane.transform = matrixFromNormal [-1,0,0]
				)
				
				(-2):
				(
					workplane.transform = matrixFromNormal [0,-1,0]
				)
				
				(-3):
				(
					workplane.transform = matrixFromNormal [0,0,-1]
				)
				
			)
			
			workplane.pos = workplanePos
		)
		catch()
	)
	
	try(workplane.pos = ((intersectRayScene  (mapScreenToWorldRay mouse.pos))[1])[2].pos)catch(workplane.pos = workplanePos)
	activegrid  = workplane
	--SetSelectFilter 8
	--completeRedraw()
	unregisterRedrawViewsCallback updateWorkplane
	registerRedrawViewsCallback updateWorkplane
	completeRedraw()
)

Thanks!
I will test your code tonight. I managed to get almost what I want by using getViewTM() wich return the matrix3 of the “active” viewport, but for now i can get with 100% accuracy only the top,bottom,front,back,left and right viewports(and when the view cube is clicked on the corner – i think this is 45 degree left-fron for example). As I see your script also return top,bottom,front,back,left and right , but I will test it tonight.Thanks again.