Merge pull request #5244 from paullee0/ArchWindow_2_SketchArch_UpdateAttachmentObject_support_take2
[ArchWindow] add SketchArch attachment support (2nd attempt)
This commit is contained in:
@@ -531,6 +531,25 @@ class _Window(ArchComponent.Component):
|
||||
obj.IfcType = "Window"
|
||||
obj.MoveWithHost = True
|
||||
|
||||
# Add features in the SketchArch External Add-on
|
||||
self.addSketchArchFeatures(obj)
|
||||
|
||||
def addSketchArchFeatures(self,obj,linkObj=None,mode=None):
|
||||
'''
|
||||
To add features in the SketchArch External Add-on (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):
|
||||
|
||||
lp = obj.PropertiesList
|
||||
@@ -580,6 +599,9 @@ class _Window(ArchComponent.Component):
|
||||
ArchComponent.Component.onDocumentRestored(self,obj)
|
||||
self.setProperties(obj)
|
||||
|
||||
# Add features in the SketchArch External Add-on
|
||||
self.addSketchArchFeatures(obj, mode='ODR')
|
||||
|
||||
def onBeforeChange(self,obj,prop):
|
||||
|
||||
if prop in ["Base","WindowParts","Placement","HoleDepth","Height","Width","Hosts"]:
|
||||
@@ -866,6 +888,39 @@ class _Window(ArchComponent.Component):
|
||||
if hasattr(obj,"Area"):
|
||||
obj.Area = obj.Width.Value * obj.Height.Value
|
||||
|
||||
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
|
||||
try:
|
||||
import ArchSketchObject # Why needed ? Should have try: addSketchArchFeatures() before ! Need 'per method' ?
|
||||
# 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
|
||||
self.addSketchArchFeatures(obj, linkObj)
|
||||
|
||||
# Execute features in the SketchArch External Add-on
|
||||
self.executeSketchArchFeatures(obj, linkObj)
|
||||
|
||||
def getSubVolume(self,obj,plac=None):
|
||||
|
||||
"returns a subvolume for cutting in a base object"
|
||||
@@ -1140,7 +1195,6 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
|
||||
pairs = [["Mode"+str(i),"Mode"+str(i+1)] for i in range(1,len(WindowOpeningModes),2)]
|
||||
self.invertPairs(pairs)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def invertHinge(self):
|
||||
|
||||
@@ -1148,8 +1202,6 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
|
||||
pairs = [["Edge6","Edge8"],["Edge5","Edge7"]]
|
||||
self.invertPairs(pairs)
|
||||
self.invertOpening()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def invertPairs(self,pairs):
|
||||
|
||||
@@ -1169,6 +1221,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||
nparts.append(part)
|
||||
if nparts != self.Object.WindowParts:
|
||||
self.Object.WindowParts = nparts
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(translate("Arch","This window has no defined opening")+"\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user