Is were a script, which purpose is select an objects visible in viewport
Forum topic · Scripts Wanted
visible in viewport selection
By anybany · 2007-05-03
Forum topic · Scripts Wanted
By anybany · 2007-05-03
Is were a script, which purpose is select an objects visible in viewport
Comments (1)
Comment policy
Try this. This script will select all objects whose positions are visible from the current orhtographic viewport. Use this as a starter and feel free to ask questions.
Hope this helps
Mobeen
--Author: Muhammad Mobeen Movania
--Last Modified: May 04 2007 10:28 pm PST
--Tested on 3dsmax5
--This script selects all objects that intersect the current
--orthographic viewport limits
try( destroydialog r_Test)
catch()
rollout r_Test "Select Visible to Viewport"
(
fn fnFindMinMax pts &minX &maxX &minY &maxY =
(
minX = pts[2].x
minY = pts[2].y
if (pts[1].x <= minX) then
(
minX = pts[1].x
maxX = pts[2].x
)
else
(
maxX = pts[1].x
)
if (pts[1].y <= minY) then
(
minY = pts[1].y
maxY = pts[2].y
)
else
(
maxY = pts[1].y
)
)
button bSelect "select"
on bSelect pressed do
(
--Get the active viewport size
local vpSize = getViewSize()
--Get the view bounds
local pts = #([0,0], vpSize)
--This will contain the viewport points in world coordinates
local tfm = #()
--Transform viewport points into the world positions
for p in pts do
(
append tfm (mapScreenToCP p)
)
local minX = 0
local minY = 0
local maxX = 0
local maxY = 0
fnFindMinMax tfm &minX &maxX &minY &maxY
print ("Min " + minX as string + ","+minY as string) print ("Max " + maxX as string + ","+maxY as string)
--Remove previous selections
clearSelection()
--Loop through all geometry and find if the geometry is inside the
--viewport limits
for g in geometry do
(
if ( g.pos.x >= minX and g.pos.x <= maxX and
g.pos.y >= minY and g.pos.y <= maxY) then
(
--add to selection
selectMore g
)
)
)
)
createdialog r_Test 200 40