VS:Set3DRot

From Vectorworks Developer
Revision as of 14:37, 12 August 2013 by Root (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Procedure Set3DRot rotates the referenced 3D object about a specified 3D point. It works with the following 3D objects: extrude, multiple extrude, sweep, mesh, 3D polygon, solid, CSG solid, group, symbol, plug-in object, NURBS curve, NURBS surface.

The difference between Set3DRot and SetRot3D is that Set3DRot adds the specified rotation to the existing rotation of the object, whereas SetRot3D does not consider the existing rotation, and merely makes the object rotation match the specified values.

PROCEDURE Set3DRot(
h :HANDLE;
xAngle :REAL;
yAngle :REAL;
zAngle :REAL;
xDistance :REAL;
yDistance :REAL;
zDistance :REAL);
def vs.Set3DRot(h, xAngle, yAngle, zAngle, xDistance, yDistance, zDistance):
    return None

Parameters

h HANDLE Handle to 3D object.
xAngle REAL X axis rotation angle.
yAngle REAL Y axis rotation angle.
zAngle REAL Z axis rotation angle.
xDistance REAL X coordinate of center of rotation.
yDistance REAL Y coordinate of center of rotation.
zDistance REAL Z coordinate of center of rotation.

Remarks

(Gerard Jonker, 5 April 2006): The xDistance and yDistance parameters use the Absolute Origin, so you have to correct for a moved User Origin (see example).

Example

VectorScript

PROCEDURE IncreaseExtr;
{This script increases extruded objects in the selection by a user requested value.}
{by Paolo, on the VectorScript bulletin board}
VAR
oggetto :HANDLE;
increaseValue :REAL;

FUNCTION Increase(h :HANDLE) :BOOLEAN;
VAR
height, width, depth :REAL;
xRot, yRot, zRot :REAL;
p0X, p0Y, p0Z :REAL;
p1X, p1Y, p1Z :REAL;
result, isMirroredXY :BOOLEAN;
BEGIN
{check if the obj is an extrusion}
if (GetType(h) = 24) THEN BEGIN
result := Get3DOrientation(h, xRot, yRot, zRot, isMirroredXY);
Get3DCntr(h, p0X, p0Y, p0Z);

SetRot3D(h, 0, 0, 0, 0, 0, 0);
{here depth = extrusion value}
Get3DInfo(h, height, width, depth);

{I increase the depth}
SET3DInfo(h, height, width, depth + increaseValue);

SET3DRot(h, xRot, yRot, zRot , 0,0,0);

Get3DCntr(h, p1X, p1Y, p1Z);

{move of the misplacement p0-p1}
Move3DObj(h, p0X-p1X, p0Y-p1Y, p0Z-p1Z);
Get3DCntr(h, p1X, p1Y, p1Z);
END;
increase := FALSE;
END;

BEGIN
{ask the value to increase}
increaseValue := RealDialog('Increase extrusions in the selection of this value','10');
{apply to the selected set of objects}
ForEachObjectInList(increase, 2, 0, oggetto);
END;
RUN(IncreaseExtr);

Python

def Increase( h ):
#{check if the obj is an extrusion}
	vs.Message(increaseValue )
	if (vs.GetType(h) == 24):
		
		result, xRot, yRot, zRot, isMirroredXY = vs.Get3DOrientation(h)
		p0, p0Z = vs.Get3DCntr(h)

	
		vs.SetRot3D(h, 0, 0, 0, 0, 0, 0)
		#{here depth = extrusion value}
		height, width, depth = vs.Get3DInfo(h)

		#{I increase the depth}
		vs.Set3DInfo(h, height, width, depth + increaseValue)

		vs.Set3DRot(h, xRot, yRot, zRot , 0,0,0)

		p1, p1Z = vs.Get3DCntr(h)

		#{move of the misplacement p0-p1}
		vs.Move3DObj(h, p0[0]-p1[0], p0[1]-p1[1], p0Z-p1Z)
		p1, p1Z = vs.Get3DCntr(h)

	increase = False
	
def IncreaseExtr():
	#{This script increases extruded objects in the selection by a user requested value.}
	#{by Paolo, on the VectorScript bulletin board}
	#{ask the value to increase}
	global increaseValue 
	increaseValue = vs.RealDialog('Increase extrusions in the selection of this value','10')
	vs.Message(increaseValue )
	#{apply to the selected set of objects}
	vs.ForEachObjectInList(Increase, 2, 0, vs.FObject())

increaseValue = 0
IncreaseExtr()
PROCEDURE Example;
BEGIN
    Poly3D(0, -100, -200,  0, 100, -200,  0, 100, 200,  0, -100, 200,  0, -100, -200);
    Set3DRot(LNewObj, 45, 45, 45,  0, 0, 0);
END;
RUN(Example);
{ Gerard Jonker, 2006 }
PROCEDURE test;	{ make sure Symbol-1 exists before running this script }
VAR	
    xAngle, yAngle, zAngle,
    xDistance, yDistance, zDistance, 
    xOrigin, yOrigin, foney: REAL;
    h	: HANDLE;
    bool	: BOOLEAN;
BEGIN
    GetOrigin(xOrigin, yOrigin); { retrieve user origin }

    Symbol('Symbol-1', 0, 0, 0); { places symbol on user origin }
    h := LNewObj; { get a handle to the symbol }
    GetSymLoc(h, xDistance, yDistance);
    Get3DCntr (h, foney, foney, zDistance); {x,y are unreliable in case of a hybrid symbol }

    xAngle := 10.12345;
    yAngle := 10.12345;
    zAngle := 10.12345;

    Set3Drot(h, xAngle, yAngle, zAngle, xOrigin + xDistance, yOrigin + yDistance, zDistance);
    { you can actually rotate a hybrid symbol using Set3DRot although it is advised not to }
    { the rotation over the x and y axes will be set back to 0 when the symbol is edited }
END;
RUN(test);
==== Python ====
<code lang="py">

Version

Availability: from All Versions

See Also

VS Functions:

VS:SetRot3D

VS Functions: [[VS:SetRot3D]]