ConstructionHistory
このオブジェクトは、PrimitiveオブジェクトのOperatorスタックです。Primitive.ConstructionHistoryプロパティを使用して
ConstructionHistory オブジェクトのリストを取得することにより、1
つずつスタックにオペレータを表示できます。
プリミティブのオペレータスタックは、オペレータの順序がオペレータが作成されたときの順序と通常一致するため、「コンストラクションヒストリ」と呼ばれます。ただし、siConstructionModeの概念から、オペレータは既存のオペレータの下に追加される場合があります。
コンストラクションヒストリは、「接続スタック」の概念を一般的にした例の 1 つです(詳細は「DataRepository.GetConnectionStackInfo」を参照)。
注:パフォーマンスを維持するために Item プロパティと Count
プロパティは実装されていないため、スタック全体のリストを表示しておき、そのオペレータが目的のオペレータであるかどうかを 1
つずつ確認してください。
' Set up the scenario (a cylinder with two operators)
Set oObj = CreatePrim( "Cylinder", "MeshSurface" )
ApplyOp "Bulge", oObj, 3, siPersistentOperation
ApplyOp "Twist", oObj, 3, siPersistentOperation
' First find the cylinder with the operators on it
Set oRoot = ActiveSceneRoot
Set oCyl = oRoot.FindChild(,,siMeshFamily)
' Now get the primitive from the cylinder and then the
' operator stack as the construction history object
Set oPrim = oCyl.ActivePrimitive
Set oOpStack = oPrim.ConstructionHistory
' This isn't a normal collection, so Count and Item
' do not work, as you can see if you uncomment these lines:
REM LogMessage "The stack contains " & oOpStack.Count & " operators."
REM LogMessage "...and the first one is: " & oOpStack.Item(0)
' Since you cannot indicate which one you want with Item,
' you need to enumerate each one to check to see whether it
' is the one you are looking for
For Each o in oOpStack
If (o = oPrim & ".bulgeop") Then
' You found it!
Set oBulgeOp = o
' Find the DeformAlong settings and toggle Y and Z
For Each p in oBulgeOp.Parameters
Select Case p.ScriptName
Case "defy"
LogMessage "Original value for DeformAlongY = " & p.Value
p.Value = not( p.Value )
LogMessage "New value = " & p.Value
Case "defz"
LogMessage "Original value for DeformAlongZ = " & p.Value
p.Value = not( p.Value )
LogMessage "New value = " & p.Value
Case Else
End Select
Next
End If
Next
REM Output of above script is:
'INFO : "Original value for DeformAlongY = False"
'INFO : "New value = True"
'INFO : "Original value for DeformAlongZ = True"
'INFO : "New value = False"
|
' The following code illustrates how to get a ConstructionHistory
' object and how to iterate the construction history using the
' For Each...Next statement:
Set oObject = Application.ActiveProject.ActiveScene.Root.AddGeometry("Sphere","MeshSurface")
ApplyOp "Twist", oObject
ApplyOp "Bend", oObject
ApplyOp "Taper", oObject
LogMessage "The " & oObject.Name & " has the following operators applied:"
For Each oOperator in oObject.ActivePrimitive.ConstructionHistory
LogMessage vbTab & oOperator.Name
Next
REM The output of the above script is:
'INFO : "The sphere has the following operators applied:"
'INFO : " Taper Op"
'INFO : " Bend Op"
'INFO : " Twist Op"
'INFO : " Geometry"
|
//jscript example showing how to
//enumerate the Operators on a geometry
var oGrid = ActiveProject.ActiveScene.Root.AddGeometry( "Sphere", "MeshSurface" ) ;
ApplyOp("Bulge", oGrid.Name, 3, siPersistentOperation);
ApplyOp("Bend", oGrid.Name, 3, siPersistentOperation);
oEnum = new Enumerator( oGrid.ActivePrimitive.ConstructionHistory );
for (;!oEnum.atEnd();oEnum.moveNext())
{
// Print the name of the operator
logmessage( oEnum.item().fullname ) ;
}
// Output of this script is:
//INFO : "sphere.polymsh.bendop"
//INFO : "sphere.polymsh.bulgeop"
//INFO : "sphere.polymsh.geom"
|