On 18/07/2016 at 09:27, xxxxxxxx wrote:
I'm working on a Python Generator and I'm confused about what is happening when the object is scaled.
Here is the python generator simple setup:
The python generator has a user data float gadget set to meter with id = 1;
def main() :
rad = op[c4d.ID_USERDATA, 1]
cube = c4d.BaseObject(c4d.Ocube)
cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_X] = rad * 2.0
cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Y] = rad * 2.0
cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Z] = rad *2.0
If the document is in 'Model' mode and I scale the python generator with the scale tool, the float gadget is updated and the object is scaled. The attribute manager coordinates for scale are not changed.
If the document is in 'Object' mode and I scale the python generator with the scale tool, the float gadget is not updated but the object is scaled. The attribute manager coordinates for scale are changed.
Scaling in 'Object' mode makes sense to me. I can see that the matrix has changed so the mesh generated by the generator should be changed accordingly.
Scaling in 'Model' mode is confusing to me. How does the python generator know what parameters to change when it is scaled in 'Model' mode? Is there some magic going on behind the scenes?
On 19/07/2016 at 01:36, xxxxxxxx wrote:
when the "Scale" tool is applied in "Model" mode it will scale (multiply) float parameters with a "length" unit (cm, m, etc.). You can easily test this with a standard parametric cube, this is not specific to the Python Generator.
On 19/07/2016 at 07:31, xxxxxxxx wrote:
I think I got it.
def main() :
rad = op[c4d.ID_USERDATA, 1] # unit meter
dummy_meter = op[c4d.ID_USERDATA, 2] # unit meter
dummy_percent = op[c4d.ID_USERDATA, 3] # unit percent
polys = [ [3,0,1,2], [3,4,5,0], [0,5,6,1], [1,6,7,2], [2,7,4,3], [5,4,7,6] ]
points = [ [0.707,0.707,0.707], [-0.707,0.707,0.707], [-0.707,-0.707,0.707], [0.707,-0.707,0.707],[0.707,-0.707,-0.707], [0.707,0.707,-0.707], [-0.707,0.707,-0.707], [-0.707,-0.707,-0.707] ]
cube = c4d.PolygonObject(8, 6)
for i in xrange(6) :
a = polys[i]
b = polys[i]
c = polys[i]
d = polys[i]
poly = c4d.CPolygon(a, b, c, d)
padr = list()
for i in xrange(8) :
padr.append(c4d.Vector(points[i], points[i], points[i]) * rad)
rad is scaled because its unit is meter.
dummy is scaled because its unit is meter.
dummy_percent is not scaled because its unit is percent.
Is the scale data generated by the scale tool in model mode accessible somewhere in the object(I'm just curious. Even if it's only possible in c++)?
On 19/07/2016 at 09:09, xxxxxxxx wrote:
what exactly do you mean with "scale data" ?
On 19/07/2016 at 10:31, xxxxxxxx wrote:
Doh!!! I did not think before I typed. You already answered the question. The data is in the object's parameters of type meter.
Thanks for your time and patients,