I spotted my error but i don't know how to fix.
With this i can set the length of cube15
#Application.SetValue("cube15.cube.length", 12.586, "")
but what if i have my cube as an object?
cube = Application.CreatePrim("Cube", "MeshSurface", "", "")
#this doesnt work:
Application.SetValue(cube.cube.length, 1, "")
what is the correct syntax?
You can skip reading the things below, but feel free to do
------------------
I have a textfile as tsv:
https://dl.dropboxusercontent.com/u/17630770/temp/output.tsv
It contains values to create boxes, the order is x y z width height depth
(where x, y and z are the center of the box)
I tested it in processing (i'm not so familiar with softimage and coding since it's more a hobby)
This is the result:
Here is the code in case it helps:
Code: Select all
import peasy.*;
PeasyCam cam;
String[] lines;
PVector[] pos;
PVector[] scale;
void setup() {
size(1024, 768, OPENGL);
cam = new PeasyCam(this, 400);
lines = loadStrings("output.tsv");
pos = new PVector[lines.length];
scale = new PVector[lines.length];
String[] tokens;
for(int i = 0; i < lines.length; i++) {
tokens = split(lines[i], "\t");
float x = float(tokens[0]);
float y = float(tokens[1]);
float z = float(tokens[2]);
float w = float(tokens[3]);
float h = float(tokens[4]);
float d = float(tokens[5]);
pos[i] = new PVector(x, y, z);
scale[i] = new PVector(w, h, d);
}
}
void draw() {
background(0);
fill(255);
PVector p, s;
for(int i = 0; i < pos.length; i++) {
p = pos[i];
s = scale[i];
pushMatrix();
translate(p.x, p.y, p.z);
box(s.x, s.y, s.z);
popMatrix();
}
}
The scale is going wrong. In processing i use pixels. In softimage i try that a box of 1x1x1 mathes up with 1 unit of the grid.
But it's way bigger. First i try to make the box 1x1x1 unit and after that scale but i think the process of making it 1x1x1 goes wrong.
This is the line:
Application.SetValue(cube, 1, "")
(o yeah the count > 10 in my code is for if i want to load less lines, then i switch it to count < 10)
Code: Select all
import csv
count = 0
with open("C:\Users\Doeke\Desktop\output.tsv") as tsv:
for line in csv.reader(tsv, delimiter="\t"): #You can also use delimiter="\t" rather than giving a dialect.
x = float(line[0])
y = float(line[1])
z = float(line[2])
w = float(line[3])
h = float(line[4])
d = float(line[5])
if count > 10:
LogMessage(line)
cube = Application.CreatePrim("Cube", "MeshSurface", "", "")
Application.SetValue(cube, 1, "")
Application.Scale("", w, h, d, "siAbsolute", "siPivot", "siObj", "siXYZ", "", "", "", "", "", "", "", 0, "")
Application.Translate("", x, y, z, "siAbsolute", "siPivot", "siObj", "siXYZ", "", "", "", "", "", "", "", "", "", 0, "")
count += 1