Why clone a line node without display properties?

image

Why clone a line node without display properties?
克隆一条直线为啥不带显示属性呢?

What do you do, what do you expect, and what happens instead? What Slicer version?

slicer 4.13
我画了一条直线如图, 并且设置了显示属性加粗和颜色…

I drew a straight line as shown in the figure, and set the display attributes bold and color…

and then clone it… get this result

Why clone a line node without display properties?

I guess the cloned node is using default markups properties, which make sense, but probably copying display properties would be a more desirable behavior. You can submit a bug report to https://issues.slicer.org and we’ll try to get to it soon.

If you copy the node programmatically then after cloning you can simply copy the content of the original node’s display node to the cloned node’s display node.

@lassoan
Howto copy the content of the original node’s display node to the cloned node’s display node except those that have been modified display properties, such as the line diameter and color of the lineNode display properties, etc. programmatically (py)?

You can copy all content of a node into another, using the CopyContent method.

1 Like
def cloneNode(modNode):
  """Create a copy from input nodes and return the new instance"""
  modClass = modNode.GetClassName()
  modCopy = slicer.mrmlScene.AddNewNodeByClass(modClass)
  modCopy.CopyContent(modNode, False)
  modCopy.SetName(f"{modNode.GetName()}_copy")
  modCopy.GetDisplayNode().CopyContent(modNode.GetDisplayNode(), False)
  modCopy.GetDisplayNode().SetVisibility3D(True)
  modCopy.GetDisplayNode().SetVisibility2D(True)
  return modCopy

@lassoan Thanks

The cloneNode function that you created takes a MRML node object as input. It fails because you passed a string as input.