ScriptSpot

Script

New Measure Distance Tool

By Digital Animation Services · 2012-04-25

Version
1.3
Version requirement
tested with max 2008 and up
Date updated
2009-06-01
Votes
1
Download
Download
Description

A macroscript tool for measuring the distance between 2 objects. Creates a feedback window giving the distance between 2 mouse click. Stays open allowing you to continue measuring until you're done. The most user-friendly method, better than the Tape Measure Helper or the Measure Distance tool. As a macroscript, once installed, it's fast and easy.

Additional Info

unzip the macro and place it in your macroscripts folder (typically: C:\Program Files\Autodesk\3ds Max XXXX\UI\MacroScripts). You'll find the macro under "DAS Tools" when you go to "Customize\Customize User Interface\Toolbars\Category: All Commands".Place the macro on any toolbar. If you are not familiar with loading macroscripts see the max help regarding Customizing the User Interface. The script will prompt you to click in the viewport to declare the beginning of the measurement. If that point is registered you'll be prompted to click a second location after which a dialog will pop up showing you the distance between the 2 clicks. You'll be prompted to contiue measuring more points or exit.
Comments (4)

fzxj520 · 2024-12-11

-- A new version of measure disatance tool that works
-- VERSION 1.1 6/2009
-- 2.5D 捕获模式 任意2点间距 --
-- MacroScript DAS_NewMeasureTool ButtonText:"New Measure Tool" Category:"DAS Tools" Tooltip:"DAS New Measure Tool"
(
execute
(

global pp1 = undefined
global pp2 = undefined
global dd = undefined
global Unittxt = ""
global ddAdj = 1
global bmapG = bitmap 200 39 color:green
global bmap = bitmap 200 39 color:[200,200,200]

(---------- 扑捉点开
snapMode.type = #2_5D
SM = snapmode.active
if ( SM == true and snapmode.type != undefined ) do ( ST = snapmode.type )
SMV = snapmode.getOSnapItemActive 7 1
snapmode.setOSnapItemActive 7 1 true -- (7) (1-6)==顶点、端点、边/线段、中点、面、中心面
snapmode.active = true
)

rollout NM "Distance"
(

button agn "Again" images:#(bmap,undefined,1,1,1,1,1) width:200 height:50 offset:[-1,-10]enabled:false border:false
label lb1 "Pick 1st Point" offset:[0,-45]

on NM open do
(
case of -- SET UP UNITS DECLARATION
(
(units.SystemType == #inches):
(

if units.DisplayType == #US then
(
case of -- inches to feet compensation if Display type is feet
(
(units.USType == #Frac_In): (ddAdj = 1 ; Unittxt = " inches")
(units.USType == #Dec_In): (ddAdj = 1 ; Unittxt = " inches")
(units.USType == #Frac_Ft): (ddAdj = 12 ; Unittxt = " ft.")
(units.USType == #Dec_Ft): (ddAdj = 12 ; Unittxt = " ft.")
(units.USType == #Ft_Frac_In): (ddAdj = 12 ; Unittxt = " ft.")
(units.USType == #Ft_Dec_In): (ddAdj = 12 ; Unittxt = " ft.")
default: (ddAdj = 1 ; Unittxt = " inches")
)
)
)
(units.SystemType == #feet): Unittxt = " ft."
(units.SystemType == #miles): Unittxt = " miles"
(units.SystemType == #millimeters): Unittxt = " mm"
(units.SystemType == #centimeters): Unittxt = " cm"
(units.SystemType == #meters): Unittxt = " meters"
(units.SystemType == #kilometers): Unittxt = " km"
default: Unittxt = ""
)

pp1 = pickPoint prompt:"Pick the 1st point" snap:#3D
if classOf pp1 == Point3 then
(
agn.images = #(bmapG,undefined,1,1,1,1,1)
lb1.text = "Pick 2nd Point"
pp2 = pickPoint prompt:"Pick the 2nd point" snap:#3D rubberband:pp1
if classOf pp2 == Point3 then
(
dd = (distance pp1 pp2)/ddAdj
ddtxt = dd as string
NM.width = (ddtxt.count + Unittxt.count) * 7
lb1.text = (dd as string + Unittxt)
agn.images = #(bmap,undefined,1,1,1,1,1)
if querybox ("Distance: " + dd as string + Unittxt + " Try Again?") title:"Distance" then
(
DestroyDialog NM
createDialog NM 90 24 100 100 escapeEnable:true
)
else DestroyDialog NM
--agn.enabled = true
)
else
(
--lb1.text = "Invalid Entry"
DestroyDialog NM -- Get rid of it and re-open to initialize in case you want to continue to measure things
createDialog NM 90 24 100 100 escapeEnable:true -- hides error warning when pick is not a point 3
)
)
else -- exit the script if "Esc" or R-Click before 1st point is chosen
(
--lb1.text = "Invalid Entry"
DestroyDialog NM
--createDialog NM 90 30 100 100 escapeEnable:true
)
-- case of -- ANOTHER WAY OF DOING IT ALLOWING FOR DIFFERENT FUNCTIONS BASED ON KEY PRESS, ETC
-- (
-- (pp1 == undefined): DestroyDialog NM
-- (pp1 == #rightClick): DestroyDialog NM
-- (classOf pp1 == Point3):
-- (
-- --pp1txt = pp1 as string
-- --NM.width = pp1txt.count * 7
-- lb1.text = "Pick 2nd Point"
--
-- pp2 = pickPoint prompt:"Pick the 2nd point" snap:#3D rubberband:pp1
-- case of
-- (
-- (pp2 == undefined): DestroyDialog NM
-- (pp2 == #rightClick): DestroyDialog NM
-- (classOf pp2 == Point3):
-- (
-- --lb1.text = pp2 as string
-- dd = distance pp1 pp2
-- ddtxt = dd as string
--
-- NM.width = (ddtxt.count + Unittxt.count) * 7
-- lb1.text = (dd as string + Unittxt)
-- )
-- (classOf pp2 == String):
-- (
-- lb1.text = "Invalid Entry"
-- DestroyDialog NM
-- createDialog NM 90 30 900 200 escapeEnable:true
-- )
-- default: DestroyDialog NM
-- )
-- pp1 = undefined
-- pp2 = undefined
-- dd = undefined
-- )
-- (classOf pp1 == String):
-- (
-- lb1.text = "Invalid Entry"
-- DestroyDialog NM
-- createDialog NM 90 30 900 200 escapeEnable:true
-- )
-- default: DestroyDialog NM
-- )
)
-- on agn pressed do -- RE-INITIALIZE
-- (
-- DestroyDialog NM
-- createDialog NM 90 24 100 100 escapeEnable:true
-- )

)
createDialog NM 90 24 100 100 escapeEnable:true --style:#(#style_toolwindow)

(---------- 扑捉点关
snapMode.type = #3D
snapmode.active = SM
if ( SM == true and ST != undefined ) do ( snapmode.type = ST )
snapmode.setOSnapItemActive 7 1 SMV
)

)
)

/**
( -- 切换捕获模式 --
if not snapMode.active then
snapMode.active = on
else case snapMode.type of
(
#2D : snapMode.type = #2_5D
#2_5D : snapMode.type = #3D
#3D : snapMode.type = #2D
)
)
**/

Please Improve

Kurai · 2014-09-10

This is much better than the Max helper because I don't have to keep deleting the lines when I've finished... which is annoying. I hope you can improve this tool so it mimics Sketchup tapemeasure.... it would be create if you could add constructions lines too.

This tool is a BIG help.... :)

barigazy · 2012-04-25

Very nice tool. Nice and simple.
Why the rollout change size (shrink) when shows distance.
Can you create also simple script (not macro)?
Put this at the and to reduce roll size a bit:

createDialog NM 90 24 100 100 escapeEnable:true \
style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

Digital Animation Services · 2012-04-26

Thanks barigazy. I'll look into that when I have a few minutes.