I am trying to write a python node that checks the orientation of a coordinate system and if the z-axis is not facing in the same up direction (0,0,1) as the world coordinate system, it should flip the z axis accordingly. However I receive this error message:
AttributeError: can’t assign to read-only property Z of type ‘Vector’
Essentially, looking for the correct syntax to manipulate the CoordinateSystem class and cannot find any documentation for it (or any of the dynamo classes for that matter).
So here is the dynamo sample. For some reason the vector can be flipped easily, but when using that to feed into creating a new coordinate system, the change does not occur. Is this a bug? FYI I am still using Dynamo 1.3 does anyone still experience this issue?
I can’t say for sure for Dynamo 1.3 but I think I have a solution.
In 2.0.1 the cs also won’t flip if you create it with a negative z vector, but you can then change the scale factor of the cs and that does flip only the Z-axis!
Interestingly, it then still considers the scale factor to be 1, not -1 as I’d have expected.
I think that’s only true if the CS is axis-aligned, though, isn’t it? Though I guess you could use CoordinateSystem.*Plane otherwise (where * is XY/YZ/ZX)… Possibly more efficient than my method, in any event
Ah, yes if the axis is not aligned I have to extract the xy plane from the coordinate system and use that to flip. But your scale vector solution also works well. I tried to select both of your responses as solutions but the page only allows one.