pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

The way XCAFDoc_ColorTool works has changed

Open ICO-Fantasy opened this issue 3 years ago • 5 comments

I upgraded my pyocc from 7.7.0 to 7.7.2 I have put the following code

doc_str = TCollection_ExtendedString("doc")
doc = TDocStd_Document(doc_str)
shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc.Main())
color_tool = XCAFDoc_DocumentTool_ColorTool(doc.Main())

replace with

doc = TDocStd_Document("doc")
shape_tool = XCAFDoc_DocumentTool.ShapeTool(doc.Main())
color_tool = XCAFDoc_DocumentTool.ColorTool(doc.Main())

The method color_tool.GetInstanceColor(shape, 0, c) works fine but color_tool.GetColor(label, 0, c) doesn't, what is the reason for this? image I am attaching the code that works fine in pyocc 7.7.0, it does not work in pyocc 7.7.2. readStepWithColor.txt

ICO-Fantasy avatar Dec 04 '23 06:12 ICO-Fantasy

It seems like you can get the color with XCAFDoc_ColorTool.GetColor(), instead of color_tool.GetColor().

@tpaviot is this intended behaviour?

daniel1v avatar Jan 16 '24 09:01 daniel1v

It seems like you can get the color with XCAFDoc_ColorTool.GetColor(), instead of color_tool.GetColor().

@tpaviot is this intended behaviour?

image The color_tool I'm using is defined like this. I don't think I can create an instance of XCAFDoc_ColorTool without XCAFDoc_DocumentTool.

ICO-Fantasy avatar Jan 16 '24 15:01 ICO-Fantasy

It seems like you can get the color with XCAFDoc_ColorTool.GetColor(), instead of color_tool.GetColor(). @tpaviot is this intended behaviour?

image The color_tool I'm using is defined like this. I don't think I can create an instance of XCAFDoc_ColorTool without XCAFDoc_DocumentTool.

You do not have to create an instance. Just call the function.

daniel1v avatar Jan 16 '24 17:01 daniel1v

daniel1v

Thank you very much, dear daniel1v. The method you provided does work. In the pyocc source code, the XCAFDoc_ColorTool.GetColor method does not use the @staticmethod decorator, but calling it directly is effective. Following your advice, the code is now running correctly.

ICO-Fantasy avatar Jan 17 '24 07:01 ICO-Fantasy

daniel1v

Thank you very much, dear daniel1v. The method you provided does work. In the pyocc source code, the XCAFDoc_ColorTool.GetColor method does not use the @staticmethod decorator, but calling it directly is effective. Following your advice, the code is now running correctly.

Yeah, that confused me too.

daniel1v avatar Jan 17 '24 08:01 daniel1v