demoObjectFactory.py

demoObjectFactory.py
1 '''
2  Demonstrates using the Factory to create objects and associate them with nodes.
3 '''
4 import MaxPlus
5 
6 # Get the class ID for the conform object which is known to not work properly
7 Conform_cid = MaxPlus.Class_ID(0x1ab13757, 0x12365b98)
8 
9 # Enumerate over all classes loaded by 3ds Max
10 for cd in MaxPlus.PluginManager.GetClassList().Classes:
11  if cd.SuperClassId == MaxPlus.SuperClassIds.GeomObject:
12  try:
13  # Skip over the conform object
14  if cd.ClassId != Conform_cid:
15 
16  print 'creating ', cd.Name
17  # Create the object
18  o = MaxPlus.Factory.CreateGeomObject(cd.ClassId)
19  if o:
20  print 'successful'
21  # Create a node and associate the object with it.
23  else:
24  print 'failed'
25  else:
26  print "The Conform object can't be created"
27  except:
28  print 'Error occured'