Merge pull request #5243 from paullee0/ArchEquipment_2_SketchArch_UpdateAttachmentObject_support_take3

[ArchEquipment] add SketchArch attachment support (3rd attempt)
This commit is contained in:
Yorik van Havre
2021-12-21 11:47:22 +01:00
committed by GitHub

View File

@@ -281,6 +281,24 @@ class _Equipment(ArchComponent.Component):
obj.IfcType = "Furnishing Element"
else:
obj.IfcType = "Undefined"
# Add features in the SketchArch External Add-on, if present
self.addSketchArchFeatures(obj)
def addSketchArchFeatures(self,obj,linkObj=None,mode=None):
'''
To add features in the SketchArch External Add-on, if present (https://github.com/paullee0/FreeCAD_SketchArch)
- import ArchSketchObject module, and
- set properties that are common to ArchObjects (including Links) and ArchSketch
to support the additional features
To install SketchArch External Add-on, see https://github.com/paullee0/FreeCAD_SketchArch#iv-install
'''
try:
import ArchSketchObject
ArchSketchObject.ArchSketch.setPropertiesLinkCommon(self, obj, linkObj, mode)
except:
pass
def setProperties(self,obj):
@@ -305,6 +323,9 @@ class _Equipment(ArchComponent.Component):
ArchComponent.Component.onDocumentRestored(self,obj)
self.setProperties(obj)
# Add features in the SketchArch External Add-on, if present
self.addSketchArchFeatures(obj)
def onChanged(self,obj,prop):
self.hideSubobjects(obj,prop)
@@ -323,6 +344,40 @@ class _Equipment(ArchComponent.Component):
base = self.processSubShapes(obj,base,pl)
self.applyShape(obj,base,pl,allowinvalid=False,allownosolid=True)
# Execute features in the SketchArch External Add-on, if present
self.executeSketchArchFeatures(obj)
def executeSketchArchFeatures(self, obj, linkObj=None, index=None, linkElement=None):
'''
To execute features in the SketchArch External Add-on (https://github.com/paullee0/FreeCAD_SketchArch)
- import ArchSketchObject module, and
- execute features that are common to ArchObjects (including Links) and ArchSketch
To install SketchArch External Add-on, see https://github.com/paullee0/FreeCAD_SketchArch#iv-install
'''
# To execute features in SketchArch External Add-on, if present
try:
import ArchSketchObject
# Execute SketchArch Feature - Intuitive Automatic Placement for Arch Windows/Doors, Equipment etc.
# see https://forum.freecadweb.org/viewtopic.php?f=23&t=50802
ArchSketchObject.updateAttachmentOffset(obj, linkObj)
except:
pass
def appLinkExecute(self, obj, linkObj, index, linkElement):
'''
Default Link Execute method() -
See https://forum.freecadweb.org/viewtopic.php?f=22&t=42184&start=10#p361124
@realthunder added support to Links to run Linked Scripted Object's methods()
'''
# Add features in the SketchArch External Add-on, if present
self.addSketchArchFeatures(obj, linkObj)
# Execute features in the SketchArch External Add-on, if present
self.executeSketchArchFeatures(obj, linkObj)
def computeAreas(self,obj):
return