8,452
edits
Paradox-01 (talk | contribs) m (scripting: decrypting merged integer flags) |
Paradox-01 (talk | contribs) m (correcting mistakes on "[25] getting and setting the position of points") |
||
Line 672: | Line 672: | ||
' '''[25] getting and setting the position of points (without selection) right after object creation''' | ' '''[25] getting and setting the position of points (without selection) right after object creation''' | ||
' | ' point positions are relative to the object's center | ||
' to get the | ' to get the absolute point positions add center to point | ||
' | ' to set the absolute point positions subtract center from point | ||
set oRoot = application.activeproject.activescene.root | set oRoot = application.activeproject.activescene.root | ||
set oObj = oRoot.addgeometry( "Cube", "MeshSurface", " | set oObj = oRoot.addgeometry( "Cube", "MeshSurface", "test" ) | ||
' to test our code move center to somewhere else | |||
Translate oObj, 9, 11, 13, siRelative, siGlobal, siCtr, siXYZ, , , , , , , , , , 0 | |||
SaveKey oObj & ".kine.local.posx," & oObj & ".kine.local.posy," & oObj & ".kine.local.posz", 1, , , , True | |||
FreezeObj oObj | FreezeObj oObj | ||
set oGeometry = oObj.activeprimitive.geometry | set oGeometry = oObj.activeprimitive.geometry | ||
aPositions = oGeometry.Points.PositionArray | aPositions = oGeometry.Points.PositionArray | ||
' | ' get old position | ||
logmessage aPositions(0, 0) | ' (xyz, point) | ||
logmessage aPositions(1, 0) | logmessage "old point 0 posx: " & aPositions(0, 0) + GetValue(oObj & ".kine.global.posx") | ||
logmessage aPositions(2, 0) | logmessage "old point 0 posy: " & aPositions(1, 0) + GetValue(oObj & ".kine.global.posy") | ||
logmessage "old point 0 posz: " & aPositions(2, 0) + GetValue(oObj & ".kine.global.posz") | |||
' | ' set new position | ||
aPositions( | aPositions(0, 0) = -7 - GetValue(oObj & ".kine.global.posx") | ||
aPositions(1, 0) = -7 - GetValue(oObj & ".kine.global.posy") | |||
aPositions(2, 0) = -7 - GetValue(oObj & ".kine.global.posz") | |||
' update the array | ' update the array | ||
oGeometry.Points.PositionArray = aPositions | oGeometry.Points.PositionArray = aPositions | ||
' | ' get new position | ||
logmessage "new point 0 posx: " & aPositions(0, 0) + GetValue(oObj & ".kine.global.posx") | |||
logmessage "new point 0 posy: " & aPositions(1, 0) + GetValue(oObj & ".kine.global.posy") | |||
logmessage "new point 0 posz: " & aPositions(2, 0) + GetValue(oObj & ".kine.global.posz") | |||
' INFO : old point 0 posx: -4 | |||
' INFO : old point 0 posy: -4 | |||
' INFO : old point 0 posz: -4 | |||
' INFO : new point 0 posx: -7 | |||
' INFO : new point 0 posy: -7 | |||
' INFO : new point 0 posz: -7 | |||
edits