Create coordinate system using model node

Hi, everyone, I’m trying to create a coordinate system which can be shown and transformed in slice view as shown in the picture below.
屏幕快照 2020-02-18 上午12.00.08
I tried using CreateModels from SlicerIGT, however, there is only one arrow head in the coordinate system. I’m wondering if the axes generated by show orientation marker in view controller can be transformed. Can this be achieved by command in python interactor?
I also tried to create a Model node that uses arrows as coordinate system and use transform module to move the coordinate system, but I’m not sure how to do this.
Does anyone know how to do this?
Thanks!

CreateModels puts an arrowhead on the first axis only to make the axes clearly distinguishable. If you added arrowheads on all axes then you would need to add alternative ways (colors, labels, etc.) to distinguish the axes.

Setting up a 2D/3D axis actor with text labels that are scaled to the window size, face the camera and properly occluded by the view content would be very hard (it will be easy to do when we add arrowheads to markups line nodes).

As an approximate solution, you can draw a coordinate system model (with arrowheads and labels created as 3D objects) in your favorite 3D modeling software, save it as STL, OBJ, or PLY, and load that into Slicer.

Hi lassoan,
Thanks for answering, I followed your advice and import a OBJ model to my Slicer, however, when I try to project my model to 2D view, I used SetSliceDisplayModeToProjection() function but it didn’t work. And there is no error or warning. When I used this function before, it worked perfectly, I used it the same way as before, don’t know why it didn’t work this time and do you have any idea how to solve it? Thanks!

Can you upload the code and which version of the slicer?

Sure, I used Slicer4.10.0, code:
upload OBJ:
slicer.util.loadModel(u’/Users/sissi/Desktop/coordinate.obj’)
coordinate = slicer.util.getNode(‘coordinate’)
Then to project it:
model = slicer.util.getNode(‘coordinate’)
model.GetDisplayNode().SetColor(0, 1, 0)
model.GetDisplayNode().SetSliceDisplayModeToProjection()
Thanks

Ok, you can active the slice visible with this code in the last of your code.

model.GetDisplayNode().SetSliceIntersectionVisibility(1)

Hi, thanks for your quick reply. I put that at the end of my code and it still doesn’t work. However, I tried again on the Coordinate system ‘Slicer IGT createmodels’ created and that worked fine. Don’t know if it’s my model that caused this problem. Can’t figure out what’s wrong.

ok, could you uploard the obj model. So, we can test this problem.

Thanks! I uploaded it in google drive.
https://drive.google.com/file/d/1Cii9YdzSsQu9rv-lVHvCXrVk9DyRXyV6/view

sorry, the google was barried for me.

How about this link?


Thanks

VTK reports that the file is corrupted: “Point array diffuse_0_0_0_255 with 2 components, only has 5878 tuples but there are 5882 points”. The issue seems to be the 4 extra vertices at the end of the file:

usemtl diffuse_0_0_0_255
v 0 20 0
p 5879
usemtl diffuse_0_0_0_255
v 0 0 -20
p 5880
usemtl diffuse_0_0_0_255
v 20 0 0
p 5881
usemtl diffuse_0_0_0_255
v 0 0 0
p 5882

If you remove them then the file loads correctly and slice projection shows up, too.

Thanks for your help! It worked!