parameters: (target, origin=None)
docstring: Apply visual properties from the Draft toolbar or another object.
  
      This function only works if the graphical interface is available
      as the visual properties are attributes of the view provider
      (`obj.ViewObject`).
  
      Parameters
      ----------
      target: App::DocumentObject
          Any type of scripted object.
  
          This object will adopt the applicable visual properties,
          `FontSize`, `TextColor`, `LineWidth`, `PointColor`, `LineColor`,
          and `ShapeColor`, defined in the Draft toolbar
          (`Gui.draftToolBar`) or will adopt
          the properties from the `origin` object.
  
          The `target` is also placed in the construction group
          if the construction mode in the Draft toolbar is active.
  
      origin: App::DocumentObject, optional
          It defaults to `None`.
          If it exists, it will provide the visual properties to assign
          to `target`, with the exception of `BoundingBox`, `Proxy`,
          `RootNode` and `Visibility`.
docstring_summary: Apply visual properties from the Draft toolbar or another object.
docstring_tokens: Apply visual properties from the Draft toolbar or another object .
function: def format_object(target, origin=None):
      """Apply visual properties from the Draft toolbar or another object.
  
      This function only works if the graphical interface is available
      as the visual properties are attributes of the view provider
      (`obj.ViewObject`).
  
      Parameters
      ----------
      target: App::DocumentObject
          Any type of scripted object.
  
          This object will adopt the applicable visual properties,
          `FontSize`, `TextColor`, `LineWidth`, `PointColor`, `LineColor`,
          and `ShapeColor`, defined in the Draft toolbar
          (`Gui.draftToolBar`) or will adopt
          the properties from the `origin` object.
  
          The `target` is also placed in the construction group
          if the construction mode in the Draft toolbar is active.
  
      origin: App::DocumentObject, optional
          It defaults to `None`.
          If it exists, it will provide the visual properties to assign
          to `target`, with the exception of `BoundingBox`, `Proxy`,
          `RootNode` and `Visibility`.
      """
      if not target:
          return
      obrep = target.ViewObject
      if not obrep:
          return
      ui = None
      if App.GuiUp:
          if hasattr(Gui, "draftToolBar"):
              ui = Gui.draftToolBar
      if ui:
          doc = App.ActiveDocument
          if ui.isConstructionMode():
              lcol = fcol = ui.getDefaultColor("constr")
              tcol = lcol
              fcol = lcol
              grp = doc.getObject("Draft_Construction")
              if not grp:
                  grp = doc.addObject("App::DocumentObjectGroup", "Draft_Construction")
                  grp.Label = utils.get_param("constructiongroupname", "Construction")
              grp.addObject(target)
              if hasattr(obrep, "Transparency"):
                  obrep.Transparency = 80
          else:
              lcol = ui.getDefaultColor("line")
              tcol = ui.getDefaultColor("text")
              fcol = ui.getDefaultColor("face")
          lcol = (float(lcol[0]), float(lcol[1]), float(lcol[2]), 0.0)
          tcol = (float(tcol[0]), float(tcol[1]), float(tcol[2]), 0.0)
          fcol = (float(fcol[0]), float(fcol[1]), float(fcol[2]), 0.0)
          lw = utils.getParam("linewidth",2)
          fs = utils.getParam("textheight",0.20)
          if not origin or not hasattr(origin, 'ViewObject'):
              if "FontSize" in obrep.PropertiesList:
                  obrep.FontSize = fs
              if "TextSize" in obrep.PropertiesList:
                  obrep.TextSize = fs
              if "TextColor" in obrep.PropertiesList:
                  obrep.TextColor = tcol
              if "LineWidth" in obrep.PropertiesList:
                  obrep.LineWidth = lw
              if "PointColor" in obrep.PropertiesList:
                  obrep.PointColor = lcol
              if "LineColor" in obrep.PropertiesList:
                  if hasattr(obrep,"FontName") and (not hasattr(obrep,"TextColor")):
                      # dimensions and other objects with text but no specific
                      # TextColor property. TODO: Add TextColor property to dimensions
                      obrep.LineColor = tcol
                  else:
                      obrep.LineColor = lcol
              if "ShapeColor" in obrep.PropertiesList:
                  obrep.ShapeColor = fcol
          else:
              matchrep = origin.ViewObject
              for p in matchrep.PropertiesList:
                  if p not in ("DisplayMode", "BoundingBox",
                               "Proxy", "RootNode", "Visibility"):
                      if p in obrep.PropertiesList:
                          if not obrep.getEditorMode(p):
                              if hasattr(getattr(matchrep, p), "Value"):
                                  val = getattr(matchrep, p).Value
                              else:
                                  val = getattr(matchrep, p)
                              try:
                                  setattr(obrep, p, val)
                              except Exception:
                                  pass
              if matchrep.DisplayMode in obrep.listDisplayModes():
                  obrep.DisplayMode = matchrep.DisplayMode
              if (hasattr(matchrep, "DiffuseColor")
                      and hasattr(obrep, "DiffuseColor")):
                  obrep.DiffuseColor = matchrep.DiffuseColor
function_tokens: def format_object ( target , origin = None ) : if not target : return obrep = target . ViewObject if not obrep : return ui = None if App . GuiUp : if hasattr ( Gui , "draftToolBar" ) : ui = Gui . draftToolBar if ui : doc = App . ActiveDocument if ui . isConstructionMode ( ) : lcol = fcol = ui . getDefaultColor ( "constr" ) tcol = lcol fcol = lcol grp = doc . getObject ( "Draft_Construction" ) if not grp : grp = doc . addObject ( "App::DocumentObjectGroup" , "Draft_Construction" ) grp . Label = utils . get_param ( "constructiongroupname" , "Construction" ) grp . addObject ( target ) if hasattr ( obrep , "Transparency" ) : obrep . Transparency = 80 else : lcol = ui . getDefaultColor ( "line" ) tcol = ui . getDefaultColor ( "text" ) fcol = ui . getDefaultColor ( "face" ) lcol = ( float ( lcol [ 0 ] ) , float ( lcol [ 1 ] ) , float ( lcol [ 2 ] ) , 0.0 ) tcol = ( float ( tcol [ 0 ] ) , float ( tcol [ 1 ] ) , float ( tcol [ 2 ] ) , 0.0 ) fcol = ( float ( fcol [ 0 ] ) , float ( fcol [ 1 ] ) , float ( fcol [ 2 ] ) , 0.0 ) lw = utils . getParam ( "linewidth" , 2 ) fs = utils . getParam ( "textheight" , 0.20 ) if not origin or not hasattr ( origin , 'ViewObject' ) : if "FontSize" in obrep . PropertiesList : obrep . FontSize = fs if "TextSize" in obrep . PropertiesList : obrep . TextSize = fs if "TextColor" in obrep . PropertiesList : obrep . TextColor = tcol if "LineWidth" in obrep . PropertiesList : obrep . LineWidth = lw if "PointColor" in obrep . PropertiesList : obrep . PointColor = lcol if "LineColor" in obrep . PropertiesList : if hasattr ( obrep , "FontName" ) and ( not hasattr ( obrep , "TextColor" ) ) : # dimensions and other objects with text but no specific # TextColor property. TODO: Add TextColor property to dimensions obrep . LineColor = tcol else : obrep . LineColor = lcol if "ShapeColor" in obrep . PropertiesList : obrep . ShapeColor = fcol else : matchrep = origin . ViewObject for p in matchrep . PropertiesList : if p not in ( "DisplayMode" , "BoundingBox" , "Proxy" , "RootNode" , "Visibility" ) : if p in obrep . PropertiesList : if not obrep . getEditorMode ( p ) : if hasattr ( getattr ( matchrep , p ) , "Value" ) : val = getattr ( matchrep , p ) . Value else : val = getattr ( matchrep , p ) try : setattr ( obrep , p , val ) except Exception : pass if matchrep . DisplayMode in obrep . listDisplayModes ( ) : obrep . DisplayMode = matchrep . DisplayMode if ( hasattr ( matchrep , "DiffuseColor" ) and hasattr ( obrep , "DiffuseColor" ) ) : obrep . DiffuseColor = matchrep . DiffuseColor