Skip to content

Resolve "Create Transform class"

Lucas POLO-LOPEZ requested to merge 13-create-transform-class into develop

Closes #13 (closed)

Methods to implement

translate(self, object: str, x: Union[float, str], y: Union[float, str], z: Union[str, float], copy: bool=False, repetitions: int=1, group=False, destination: str="", material: str="")

It must be noted that group, destination and material can only take a value other than their default if the value of copy is True.

If a destination is specified, it must be checked whether the component exist. If it does not, the destination component should be created prior to the translate command. Since this operation will have to be done by other methods in the class, it will be convenient to define a hidden method to implement this.

vba = (
    'With Transform\n' +
    '.Reset \n' +
    '.Name "{}"\n'.format(object) +
    '.Vector "{}", "{}", "{}"\n'.format(tranParams["x"], tranParams["y"], tranParams["z"]) +
    '.UsePickedPoints "False"\n' +
    '.InvertPickedPoints "False"\n' +
    '.MultipleObjects "{}"\n'.format(copy) +
    '.GroupObjects "False"\n' +
    '.Repetitions "{:d}"\n'.format(repetitions) +
    '.MultipleSelection "False"\n' +
    '.Destination "{}"\n'.format(destination) +
    '.Material "{}"\n'.format(material) +
    '.Transform "Shape", "Translate"\n' +
    'End With'
    )

scale(self, object: str, x: Union[float, str], y: Union[float, str], z: Union[str, float], x0: Union[float, str]=0.0, y0: Union[float, str]=0.0, z0: Union[float, str]=0.0, origin: str="object", copy: bool=False, repetitions: int=1, group=False, destination: str="", material: str="")

It must be noted that group, destination and material can only take a value other than their default if the value of copy is True.

origin can be either "free" or "object". When "free" is selected, x0, y0 and z0 will be used as origin for the scaling operation ("Free" in VBA). When "object" is selected, the center of the object will be used as origin ("CommonCenter" in VBA). In the latter case, the values of x0, y0 and z0 will have no impact on the operation.

vba = (
    'With Transform\n' +
    '.Reset\n' +
    '.Name "{}"\n'.format(object) +
    '.Origin "Free"\n' +
    '.Center "{}", "{}", "{}"\n'.format(tranParams["x0"], tranParams["y0"], tranParams["z0"]) +
    '.ScaleFactor "{}", "{}", "{}"\n'.format(tranParams["x"], tranParams["y"], tranParams["z"]) +
    '.MultipleObjects "{}"\n'.format(copy) +
    '.GroupObjects "False"\n' +
    '.Repetitions "{:d}"\n'.format(repetitions) +
    '.MultipleSelection "False"\n' +
    '.Destination "{}"\n'.format(destination) +
    '.Material "{}"\n'.format(material) +
    '.Transform "Shape", "Scale"\n' +
    'End With'
    )

rotate(self, object: str, x: Union[float, str], y: Union[float, str], z: Union[str, float], x0: Union[float, str]=0.0, y0: Union[float, str]=0.0, z0: Union[float, str]=0.0, origin: str="object", copy: bool=False, repetitions: int=1, group=False, destination: str="", material: str="")

x, y and z denote the rotation angle (in degrees) along each of these axes.

origin can be either "free" or "object". When "free" is selected, x0, y0 and z0 will be used as origin for the scaling operation ("Free" in VBA). When "object" is selected, the center of the object will be used as origin ("CommonCenter" in VBA). In the latter case, the values of x0, y0 and z0 will have no impact on the operation.

vba = (
    'With Transform\n' +
    '.Reset\n' +
    '.Name "{}"\n'.format(object) +
    '.Origin "Free"\n' +
    '.Center "{}", "{}", "{}"\n'.format(tranParams["x0"], tranParams["y0"], tranParams["z0"]) +
    '.Angle "{}", "{}", "{}"\n'.format(tranParams["x"], tranParams["y"], tranParams["z"]) +
    '.MultipleObjects "{}"\n'.format(copy) +
    '.GroupObjects "False"\n' +
    '.Repetitions "{:d}"\n'.format(repetitions) +
    '.MultipleSelection "False"\n' +
    '.Destination "{}"\n'.format(destination) +
    '.Material "{}"\n'.format(material) +
    '.Transform "Shape", "Rotate"\n' +
    'End With'
    )

mirror(self, object: str, x: Union[float, str], y: Union[float, str], z: Union[str, float], x0: Union[float, str]=0.0, y0: Union[float, str]=0.0, z0: Union[float, str]=0.0, origin: str="object", copy: bool=False, repetitions: int=1, group=False, destination: str="", material: str="")

x, y and z denote the normal of the mirroring plane.

origin can be either "free" or "object". When "free" is selected, x0, y0 and z0 will be used as origin for the scaling operation ("Free" in VBA). When "object" is selected, the center of the object will be used as origin ("CommonCenter" in VBA). In the latter case, the values of x0, y0 and z0 will have no impact on the operation.

vba = (
    'With Transform\n' +
    '.Reset\n' +
    '.Name "{}"\n'.format(object) +
    '.Origin "Free"\n' +
    '.Center "{}", "{}", "{}"\n'.format(tranParams["x0"], tranParams["y0"], tranParams["z0"]) +
    '.PlaneNormal "{}", "{}", "{}"\n'.format(tranParams["x"], tranParams["y"], tranParams["z"]) +
    '.MultipleObjects "{}"\n'.format(copy) +
    '.GroupObjects "False"\n' +
    '.Repetitions "{:d}"\n'.format(repetitions) +
    '.MultipleSelection "False"\n' +
    '.Destination "{}"\n'.format(destination) +
    '.Material "{}"\n'.format(material) +
    '.Transform "Shape", "Mirror"\n' +
    'End With'
    )
Edited by Lucas POLO-LOPEZ

Merge request reports

Loading