CollisionObject.CollisionProxy Class Reference

Proxy class for a FeaturePython Collision instance. More...

Inheritance diagram for CollisionObject.CollisionProxy:

Public Member Functions

def __init__ (self, fp, shape=None, cause1=None, cause2=None)
 Initialization method for CollisionProxy. More...
 
def onDocumentRestored (self, fp)
 Method called when document is restored to make sure everything is as it was. More...
 
def setProperties (self, fp, cause1=None, cause2=None)
 Method to set properties during initialization or document restoration. More...
 

Detailed Description

Proxy class for a FeaturePython Collision instance.

To connect this Proxy object to a DocumentObjectGroupPython CollisionDetector do:

    a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                         "Collision")
    CollisionProxy(a, shape, cause1, cause2)

Definition at line 55 of file CollisionObject.py.

Constructor & Destructor Documentation

◆ __init__()

def CollisionObject.CollisionProxy.__init__ (   self,
  fp,
  shape = None,
  cause1 = None,
  cause2 = None 
)

Initialization method for CollisionProxy.

A class instance is created and made a Proxy for a generic FeaturePython Collision object. During initialization number of properties are specified and preset. An object shape is supplied and the object is labeled so its known which objects caused this collision.

Parameters
fpA barebone FeaturePython Server object to be extended.
shapeA Solid object defining the shape of an intersection.
cause1An FreeCAD object observed intersecting with the cause2.
cause2An FreeCAD object observed intersecting with the cause1.

Definition at line 71 of file CollisionObject.py.

71  def __init__(self, fp, shape=None, cause1=None, cause2=None):
72  if shape is not None:
73  fp.Shape = shape
74  if cause1 is not None and cause2 is not None:
75  fp.Label = cause1.Label + " x " + cause2.Label
76  self.setProperties(fp, cause1=cause1, cause2=cause2)
77  fp.Proxy = self
78 

Member Function Documentation

◆ onDocumentRestored()

def CollisionObject.CollisionProxy.onDocumentRestored (   self,
  fp 
)

Method called when document is restored to make sure everything is as it was.

Reinitialization it creates properties and sets them to default values, if they were not restored automatically. Properties of connected ViewObject are also recreated and reset if necessary.

Parameters
fpA restored FeaturePython CollisionObject object.

Definition at line 89 of file CollisionObject.py.

89  def onDocumentRestored(self, fp):
90  self.setProperties(fp)
91  fp.ViewObject.Proxy.setProperties(
92  fp.ViewObject)
93 

◆ setProperties()

def CollisionObject.CollisionProxy.setProperties (   self,
  fp,
  cause1 = None,
  cause2 = None 
)

Method to set properties during initialization or document restoration.

The properties are set if they are not already present. Later they are set read only, because an user is not allowed to edit any instance of the CollisionObject.

Parameters
fpA restored or barebone FeaturePython CollisionObject object.

Definition at line 104 of file CollisionObject.py.

104  def setProperties(self, fp, cause1=None, cause2=None):
105  if not hasattr(fp, "CausedBy"):
106  fp.addProperty(
107  "App::PropertyLinkList", "CausedBy", "Collision",
108  "Objects that made this collision").CausedBy = [cause1, cause2]
109  if not hasattr(fp, "Volume"):
110  fp.addProperty(
111  "App::PropertyVolume", "Volume", "Collision",
112  "Overlapping volume of interfering objects."
113  ).Volume = fp.Shape.Volume
114 
115  fp.setEditorMode("Placement", 1)
116  fp.setEditorMode("CausedBy", 1)
117  fp.setEditorMode("Volume", 1)
118  fp.setEditorMode("Label", 1)
119 
120  # Add ViewObject to __dict__ so that it can be accessed using
121  # __getattribute__
122  fp.__dict__["ViewObject"] = fp.ViewObject
123 
124 

The documentation for this class was generated from the following file: