group.ofs 2.29 KB
Newer Older
1
core.clearAll()
Matthias Möller's avatar
Matthias Möller committed
2 3
//Group 20 Objects
for (i=0; i < 20;++i)
4 5 6
{
  primitivesgenerator.addSphere()
}
Matthias Möller's avatar
Matthias Möller committed
7 8
datacontrol.setAllTarget()
var list = datacontrol.getTargetObjects(DataType("TriangleMesh"));
9 10

//Check, if group was created
Matthias Möller's avatar
Matthias Möller committed
11
groupid = datacontrol.groupObjects(list)
12 13 14 15 16 17
if (groupid == -1)
{
  print("unable to create a group with 20 objects")
  core.exitFailure()
}

Matthias Möller's avatar
Matthias Möller committed
18 19
if (datacontrol.groupCount() != 1)
{
Matthias Möller's avatar
Matthias Möller committed
20
  print("Group 20 Objects failed")
21 22 23 24
  print("unexpected group count")
  print("number of groups: " + datacontrol.groupCount())
  print("expected number of groups: 1") 
  core.exitFailure()
Matthias Möller's avatar
Matthias Möller committed
25 26 27 28 29 30 31 32 33
}
datacontrol.clearAllTarget()

//Group Object and Group
id = primitivesgenerator.addSphere()
list = [groupid,id]
datacontrol.groupObjects(list)
if (datacontrol.groupCount() != 2)
{
Matthias Möller's avatar
Matthias Möller committed
34
  print("Group Object and Group failed")
35 36 37 38
  print("unexpected group count")
  print("number of groups: " + datacontrol.groupCount())
  print("expected number of groups: 2") 
  core.exitFailure()
Matthias Möller's avatar
Matthias Möller committed
39 40 41 42 43 44 45 46 47
}
datacontrol.clearAllTarget()

//Group multiple Groups
id = primitivesgenerator.addSphere()
id2 = primitivesgenerator.addSphere()
list = [id2,id]
groupid2 = datacontrol.groupObjects(list)

48 49
if (datacontrol.groupCount() != 3)
{
Matthias Möller's avatar
Matthias Möller committed
50
  print("Group multiple Groups failed")
51 52 53 54
  print("unexpected group count")
  print("number of groups: " + datacontrol.groupCount())
  print("expected number of groups: 3") 
  core.exitFailure()
Matthias Möller's avatar
Matthias Möller committed
55 56 57 58 59 60 61 62 63 64 65
}

//Ungroup
datacontrol.unGroupObject(groupid2)
if (datacontrol.groupCount() != 2)
{
  print("Ungroup failed")
  print("unexpected group count")
  print("number of groups: " + datacontrol.groupCount())
  print("expected number of groups: 2") 
  core.exitFailure()
66 67 68 69 70 71 72 73 74
}

//add object to existing group
core.clearAll()
id1 = primitivesgenerator.addSphere()
id2 = primitivesgenerator.addSphere()
id3 = primitivesgenerator.addSphere()

groupid = datacontrol.groupObjects([id1,id2])
Matthias Möller's avatar
Matthias Möller committed
75
datacontrol.addObjectToGroup(id3,groupid)
76 77 78 79 80 81 82 83 84 85 86

datacontrol.groupObjects([id1,id2,id3])//Can be done, if all objects are in the same group
if (datacontrol.groupCount() != 2)
{
  print("Add to Group failed.")
  print("unexpected group count")
  print("number of groups: " + datacontrol.groupCount())
  print("expected number of groups: 2") 
  core.exitFailure()
}

Matthias Möller's avatar
Matthias Möller committed
87
if (datacontrol.addObjectToGroup(id3,id2))
88 89 90
{
  print("Could add an object to an object which is not a Group.")
  core.exitFailure();
91
}