8,452
edits
Paradox-01 (talk | contribs) m (DAE and FBX export) |
Paradox-01 (talk | contribs) (how to get position of points (moving and sorting more content from MT main page)) |
||
Line 176: | Line 176: | ||
''' | '''Get all material libraries and materials | ||
for each ml in Application.ActiveProject.ActiveScene.MaterialLibraries | for each ml in Application.ActiveProject.ActiveScene.MaterialLibraries | ||
Line 203: | Line 203: | ||
''' | '''Check an object's main material for TwoSided-ness''' | ||
' test and toggles an object's main material for TwoSided-ness | ' test and toggles an object's main material for TwoSided-ness | ||
Line 291: | Line 291: | ||
==== | ====Layers==== | ||
'''check if obj is member of layer''' | '''check if obj is member of layer''' | ||
logmessage isMemberOfLayer(selection(0), "layerNameToTest") | logmessage isMemberOfLayer(selection(0), "layerNameToTest") | ||
Line 308: | Line 308: | ||
''' | '''Get layer name of an object''' | ||
logmessage RecursiveEnum (selection(0), false, false) | logmessage RecursiveEnum (selection(0), false, false) | ||
Line 725: | Line 725: | ||
End Select | End Select | ||
''' | '''Via CMD''' | ||
' relative path | ' relative path | ||
Line 768: | Line 768: | ||
''' | '''Via winmgmts''' | ||
' slightly modified code from [http://blogs.technet.com/b/heyscriptingguy/archive/2006/12/08/how-can-i-start-a-process-and-then-wait-for-the-process-to-end-before-terminating-the-script.aspx that site] | ' slightly modified code from [http://blogs.technet.com/b/heyscriptingguy/archive/2006/12/08/how-can-i-start-a-process-and-then-wait-for-the-process-to-end-before-terminating-the-script.aspx that site] | ||
Line 875: | Line 875: | ||
=== | ===Import DAE (and get name)=== | ||
Sometimes you want to get the name of the object you just imported. | Sometimes you want to get the name of the object you just imported. | ||
Line 1,293: | Line 1,293: | ||
End Select | End Select | ||
end sub | end sub | ||
==3D mesh== | |||
'''Bounding box values''' | |||
' this could be useful to create a bounding box for [[OBD_talk:OFGA#XML|OFGA files]] | |||
' let's get the bounding box of a simple cylinder | |||
' the output values will be absolute positions | |||
CreatePrim "Cylinder", "MeshSurface" | |||
dim xmin, ymin, zmin, xmax, ymax, zmax | |||
dim list | |||
'if you use SelectionList the objects will be treated as one single object | |||
'set list = GetValue( "SelectionList" ) | |||
set list = GetValue( selection(0) ) | |||
GetBBox list, TRUE, xmin, ymin, zmin, xmax, ymax, zmax | |||
LogMessage "Lower Bound: " & xmin & " / " & ymin & " / " & zmin | |||
LogMessage "Upper Bound: " & xmax & " / " & ymax & " / " & zmax | |||
' expected output: | |||
' INFO : Lower Bound: -1 / -2 / -1 | |||
' INFO : Upper Bound: 1 / 2 / 1 | |||
===Points=== | |||
===Get position of points (with selection mode point)=== | |||
' a point must be selected | |||
' gets xyz position of first selected point of the first selected object | |||
logmessage Selection(0).SubComponent.ComponentCollection(0).position.x | |||
logmessage Selection(0).SubComponent.ComponentCollection(0).position.y | |||
logmessage Selection(0).SubComponent.ComponentCollection(0).position.z | |||
===Get position of points (with selection mode object)=== | |||
' an object must be selected | |||
' gets xyz position of point 0 of the first selected object | |||
logmessage selection(0).activeprimitive.geometry.Points(0).Position.x | |||
logmessage selection(0).activeprimitive.geometry.Points(0).Position.y | |||
logmessage selection(0).activeprimitive.geometry.Points(0).Position.z | |||
===Get and set position of points (without selection) right after object creation=== | |||
' point positions are relative to the object's center | |||
' 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 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 | |||
set oGeometry = oObj.activeprimitive.geometry | |||
aPositions = oGeometry.Points.PositionArray | |||
' get old position | |||
' (xyz, point) | |||
logmessage "old point 0 posx: " & aPositions(0, 0) + GetValue(oObj & ".kine.global.posx") | |||
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(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 | |||
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 | |||
===Get global point position=== | |||
set oObj = selection(0) | |||
set oTrans = oObj.Kinematics.Local.Transform | |||
set oPoint0 = oObj.ActivePrimitive.Geometry.Points(0) | |||
set oPoint7 = oObj.ActivePrimitive.Geometry.Points(7) | |||
set oPos0 = oPoint0.Position | |||
set oPos7 = oPoint7.Position | |||
' scaling must be frozen to 1 before we can calculate the size from local values | |||
ResetTransform selection(0), siCtr, siScl, siXYZ | |||
logmessage "local p0: "& oPos0.X & " " & oPos0.Y & " " & oPos0.Z | |||
set oGlobalPos0 = XSIMath.MapObjectPositionToWorldSpace( oTrans, oPos0) | |||
logmessage "global p0: "& oGlobalPos0.X & " " & oGlobalPos0.Y & " " & oGlobalPos0.Z | |||
logmessage "local p7: "& oPos7.X & " " & oPos7.Y & " " & oPos7.Z | |||
set oGlobalPos7 = XSIMath.MapObjectPositionToWorldSpace( oTrans, oPos7) | |||
logmessage "global p7: "& oGlobalPos7.X & " " & oGlobalPos7.Y & " " & oGlobalPos7.Z | |||
logmessage "size: " & oPos7.X - oPos0.X & " " & _ | |||
oPos7.Y - oPos0.Y & " " & _ | |||
oPos7.Z - oPos0.Z | |||
' with a rotation of: -3,8792 16,4039 -13,5017 | |||
' INFO : local p0: -4 -4 -4 | |||
' INFO : local p7: 4 4 4 | |||
' INFO : global p0: -5,74764582364017 -3,00250371537919 -2,43916767056426 ' TRGV start point | |||
' INFO : global p7: 5,74764582364017 3,00250371537919 2,43916767056426 | |||
' INFO : size: 8 8 8 | |||
===Edges=== | |||
... | |||
===Polygons=== | |||
... | |||
==Property Page== | ==Property Page== |
edits