# Place an Objet with obj.SetMg(m)

On 04/07/2014 at 00:35, xxxxxxxx wrote:

Hi,

I want to place an Object on a given global Koordinate.

What i have is a Matrix with 16 Values like:
"1,0,0,0,0,1,0,0,0,0,1,0,0,0,5,1.439"

I read the documentation and found in the Topic "Matrix Fundamentals"
that my matix is like this:

``````
1     0     0     0      1     0     0     0
v0.x v1.x v2.x v3.x     0     1     0     0
m = v0.y v1.y v2.y v3.y = 0     0     1     0
v0.z v1.z v2.z V3.z     0     0     1   1.439

``````

Here my question:
How can I convert my Data-Structure so, that i can write it in the command
obj.SetMg(Matrix)

here my aktual code

``````
coord = LINEDATA.split(",")
#print coord
#print ("Datenzeile enthält " + str(len (coord)) + " Datensätze")
MA1 = float(coord[0])
MA2 = float(coord[1])
MA3 = float(coord[2])
MA4 = float(coord[3])
MA5 = float(coord[4])
MA6 = float(coord[5])
MA7 = float(coord[6])
MA8 = float(coord[7])
MA9 = float(coord[8])
MA10 = float(coord[9])
MA11 = float(coord[10])
MA12 = float(coord[11])
MA13 = float(coord[12])
MA14 = float(coord[13])
MA15 = float(coord[14])
MA16 = float(coord[15])

Matrix = [[MA1,MA2,MA3,MA4],[MA5,MA6,MA7,MA8],[MA9,MA10,MA11,MA12],[MA13,MA14,MA15,MA16]]
print Matrix

#c4d.SetPoint(i,c4d.Vector(x,y,z))
obj = c4d.BaseObject(c4d.Onull)        # Create new cube
#obj.SetRelPos(c4d.Vector(20))           # Set position of cube
obj.SetMg(Matrix)
doc.InsertObject(obj)                   # Insert object in document
``````

Thanks a lot

On 04/07/2014 at 03:12, xxxxxxxx wrote:

Why don't you use the given function in that matrix chapter:
You only need to define v0 - offset and v1,v2,v3 - scale and rotation.

E.g. SetGlobalScale(obj, c4d.Vector(1.0, 1.0, 1.439))

``````SetGlobalPosition(obj, pos) # Sets the global position of obj to pos
SetGlobalRotation(obj, rot) # Sets the global rotation of obj to rot
SetGlobalScale(obj, scale)  # Sets the global scale of obj to scale
``````

On 04/07/2014 at 05:31, xxxxxxxx wrote:

it sounds so easy
but:
how do I define v_0 (i think this is the offset
how do I define v_1
how do I define v_2
how do I define v_3
how do I define pos
how do I define rot
how do I define scale

I know it is in my linedata
here an example: "1,0,0,0,0,1,0,0,0,0,1,0,0,0,5,1.439"
But i dont know how to convert it.

Sorry for sutch stupid questions

Here is my actual code

``````
for line in DATA:
LINEDATA = line.strip()                    #lese den Zeileninhalt ohne rechte Leerzeichen
if (LINEDATA.find (SUCHSTRING_DATA) != -1) :
l = len(SUCHSTRING_DATA)
LINEDATA = LINEDATA[l:]
LINEDATA = LINEDATA[:-4]
coord = LINEDATA.split(",")

print "Begin neuer Datensatz"

# Umwandlung in floating
for i in range(16) :
coord[i] = float(coord[i])
#print ("Coord", i , "= ",coord[i])
#print i
continue

print (coord)

# Definition der Vektoren
v_1 = c4d.Vector( coord[5] , coord[9] , coord[13] )
v_2 = c4d.Vector( coord[6] , coord[10] , coord[14] )
v_3 = c4d.Vector( coord[7] , coord[11] , coord[15] )
off = c4d.Vector(0,0,0)

print ( v_1 , v_2 , v_3, off)
print ()
print (v_1)
print (v_2)
print (v_3)
print (off)

mat = (v_1,v_2,v_3,off)

#c4d.SetPoint(i,c4d.Vector(x,y,z))
obj = c4d.BaseObject(c4d.Onull)        # Create new nullobject
#obj.SetRelPos(c4d.Vector(20))           # Set position of cube
obj.SetMg(mat)
doc.InsertObject(obj)                   # Insert object in document

``````

On 04/07/2014 at 07:01, xxxxxxxx wrote:

Looks good.
But make

mat = (v_1,v_2,v_3,off)

mat = c4d.Matrix(off, v_1, v_2, v_3)