demoHitTest.py

demoHitTest.py
1 '''
2  Performs a hit test on an object in the active viewport.
3 '''
4 import MaxPlus
5 
6 
7 def main():
8  obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Sphere)
9  obj.ParameterBlock.Radius.Value = 50.0
10  node = MaxPlus.Factory.CreateNode(obj)
12  hittype = MaxPlus.Constants.HittypeSolid
13  hitflags = MaxPlus.Constants.HitAnysolid
14  pt = MaxPlus.IPoint2(400, 200)
15  hit = obj.HitTest(node, hittype, 1, hitflags, pt, vp)
16  print 'hit succes', hit, 'for point', pt
17  pt = MaxPlus.IPoint2(0, 0)
18  hit = obj.HitTest(node, hittype, 1, hitflags, pt, vp)
19  print 'hit success', hit, 'for point', pt
20 
21 if __name__ == "__main__":
22  main()