ScriptSpot

Forum topic · General Scripting

Help with snap markers - max 2019

By jsrocha · 2019-04-02

Description

Hey guys, how are you?
I had a script that was written by a friend of mine, but it´s not working properly in max 2019. In fact it works, but it doesn’t show the snap markers when clicking the points in the viewport (http://prntscr.com/n6lnm0). The script moves an object in Z angle, using two reference points (similar to Autocad’s move command). Does anyone knows how to solve this? Below is the code:

(
snapmode.active = true
posSource = undefined
posTarget = undefined
pickedPoint = undefined
tool pickOnePoint
(
on mousePoint click_no do
(
if click_no == 1 then
(
pickedPoint = worldPoint
)
)
)
pick_result = startTool pickOnePoint numPoints:1
if pick_result != undefined and pick_result != #abort and pick_result != #escape then
(
posSource = pickedPoint
pick_result = startTool pickOnePoint numPoints:1
if pick_result != undefined and pick_result != #abort and pick_result != #escape then
(
posTarget = pickedPoint
)
)
moveValue = [0, 0, (posTarget.z - posSource.z)]
for obj in selection where not isGroupMember obj or isOpenGroupMember obj do move obj moveValue
)

Thanks in advance,

Jsrocha

Comments (2)

jsrocha · 2019-04-04

Thanks Miauu, works just fine!
Cheers,

Jsrocha

.

miauu · 2019-04-03


(	
	local posSource = undefined
	local posTarget = undefined

	local curSnapMode = snapMode.active
	local curSnapType = snapMode.type
	snapMode.active = true
	snapMode.type = #3D

	posSource = pickPoint snap:#3d 
	if classof posSource == point3 do
		posTarget = pickPoint snap:#3d rubberBand:posSource 

	snapMode.active = curSnapMode
	try(snapMode.type = curSnapType)catch()	
	if classof posSource == point3 and classof posTarget == point3 do
	(	
		moveValue = [0, 0, (posTarget.z - posSource.z)]
		for obj in selection where not isGroupMember obj or isOpenGroupMember obj do move obj moveValue
	)
)