# Modify Vector Variable within CoordinateSystem

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).

Any help would be appreciated - thanks!

@danieljackieucla

Could you post you dyn please?

Hi Daniel

I suppose we can query the axes of a coordinate system but can’t modify it.
My understanding to this is rotating in local space about X/Y axis, minus/plus 180 degrees.

You might want to dive into the topic “Homogeneous Transformation” for a comprehensive explanation in order to deal with more generic situations.

1 Like

Taking the origin, xAxis, yAxis and a reversed zAxis of the CS to construct a new CS if the xAxis and yAxis remain unchanged is needed. I guess it should match the definition of “Flip” better.

Nevertheless it won’t work, I think CS in Dynamo complies with right-hand system. So I suppose it can’t be “Flipped” like this.

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?

coordinate system flip test2.dyn (14.5 KB)

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.

2 Likes

wow

It works in 1.3 as well!

1 Like

Seems like CoordinateSystem.Mirror should serve the purpose

2 Likes

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

1 Like

Thanks Vikram, that definitely seems to be the simplest solution but still curious why the CoordinateSystem class variables cannot be manipulated the other way I was attempting to initially.

1 Like

Wut the hell, I want to click on that Like button but accidentally clicked on Uncheck Soluton Button:sob:

I am very very sorry. It was an accident.

1 Like

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.

1 Like