Merge pull request #7200 from Roy-043/Draft-Fix-color-handling-in-make_point.py

Draft: Fix color handling in make_point.py
This commit is contained in:
Yorik van Havre
2022-07-18 10:43:29 +02:00
committed by GitHub

View File

@@ -45,7 +45,7 @@ def make_point(X=0, Y=0, Z=0, color=None, name="Point", point_size=5):
Parameters
----------
X :
X :
float -> X coordinate of the point
Base.Vector -> Ignore Y and Z coordinates and create the point
from the vector.
@@ -59,9 +59,9 @@ def make_point(X=0, Y=0, Z=0, color=None, name="Point", point_size=5):
color : (R, G, B)
Point color as RGB
example to create a colored point:
make_point(0,0,0,(1,0,0)) # color = red
make_point(0, 0, 0, (1, 0, 0)) # color = red
example to change the color, make sure values are floats:
p1.ViewObject.PointColor =(0.0,0.0,1.0)
p1.ViewObject.PointColor = (0.0, 0.0, 1.0)
"""
if not App.ActiveDocument:
App.Console.PrintError("No active document. Aborting\n")
@@ -76,18 +76,13 @@ def make_point(X=0, Y=0, Z=0, color=None, name="Point", point_size=5):
Point(obj, X, Y, Z)
# TODO: Check if this is a repetition:
obj.X = X
obj.Y = Y
obj.Z = Z
if App.GuiUp:
ViewProviderPoint(obj.ViewObject)
if hasattr(Gui,"draftToolBar") and (not color):
color = Gui.draftToolBar.getDefaultColor('line')
obj.ViewObject.PointColor = (float(color[0]), float(color[1]), float(color[2]))
if hasattr(Gui,"draftToolBar") and color is None:
color = Gui.draftToolBar.getDefaultColor("line")
if color is not None:
obj.ViewObject.PointColor = (float(color[0]), float(color[1]), float(color[2]))
obj.ViewObject.PointSize = point_size
obj.ViewObject.Visibility = True
gui_utils.select(obj)
return obj