BIM: fix some imports and cleanup miscellaneous (#20914)
This commit is contained in:
@@ -37,6 +37,7 @@ import os
|
||||
import tempfile
|
||||
|
||||
import FreeCAD
|
||||
import Arch
|
||||
import ArchCommands
|
||||
import ArchIFC
|
||||
import Draft
|
||||
@@ -938,7 +939,7 @@ class ViewProviderBuildingPart:
|
||||
no = Draft.clone(o)
|
||||
Draft.move(no,FreeCAD.Vector(0,0,height))
|
||||
ng.append(no)
|
||||
nobj = makeBuildingPart()
|
||||
nobj = Arch.makeBuildingPart()
|
||||
Draft.formatObject(nobj,self.Object)
|
||||
nobj.Placement = self.Object.Placement
|
||||
nobj.Placement.move(FreeCAD.Vector(0,0,height))
|
||||
|
||||
@@ -909,7 +909,7 @@ def saveiv(scene,filename):
|
||||
wa=coin.SoWriteAction()
|
||||
wa.getOutput().openFile(filename)
|
||||
wa.getOutput().setBinary(False)
|
||||
wa.apply(sc)
|
||||
wa.apply(scene)
|
||||
wa.getOutput().closeFile()
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ class BIM_Diff:
|
||||
# what will be compared: IDs, geometry, materials. Everything else is discarded.
|
||||
from PySide import QtGui
|
||||
import Draft
|
||||
import Part
|
||||
|
||||
MOVE_TOLERANCE = 0.2 # the max allowed move in mm
|
||||
VOL_TOLERANCE = 250 # the max allowed volume diff in mm^3
|
||||
|
||||
@@ -91,58 +91,4 @@ class Arch_Equipment:
|
||||
return
|
||||
|
||||
|
||||
class Arch_3Views:
|
||||
|
||||
# OBSOLETE
|
||||
|
||||
"the Arch 3Views command definition"
|
||||
|
||||
def GetResources(self):
|
||||
|
||||
return {'Pixmap' : 'Arch_3Views',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Arch_3Views","3 views from mesh"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Arch_3Views","Creates 3 views (top, front, side) from a mesh-based object")}
|
||||
|
||||
def IsActive(self):
|
||||
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
def Activated(self):
|
||||
|
||||
s = FreeCADGui.Selection.getSelection()
|
||||
if len(s) != 1:
|
||||
FreeCAD.Console.PrintError(translate("Arch","You must select exactly one base object"))
|
||||
else:
|
||||
obj = s[0]
|
||||
if not obj.isDerivedFrom("Mesh::Feature"):
|
||||
FreeCAD.Console.PrintError(translate("Arch","The selected object must be a mesh"))
|
||||
else:
|
||||
if obj.Mesh.CountFacets > 1000:
|
||||
msgBox = QtGui.QMessageBox()
|
||||
msgBox.setText(translate("Arch","This mesh has more than 1000 facets."))
|
||||
msgBox.setInformativeText(translate("Arch","This operation can take a long time. Proceed?"))
|
||||
msgBox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
|
||||
msgBox.setDefaultButton(QtGui.QMessageBox.Cancel)
|
||||
ret = msgBox.exec_()
|
||||
if ret == QtGui.QMessageBox.Cancel:
|
||||
return
|
||||
elif obj.Mesh.CountFacets >= 500:
|
||||
FreeCAD.Console.PrintWarning(translate("Arch","The mesh has more than 500 facets. This will take a couple of minutes..."))
|
||||
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create 3 views")))
|
||||
FreeCADGui.addModule("Arch")
|
||||
FreeCADGui.addModule("Part")
|
||||
FreeCADGui.doCommand("s1 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(0,0,-1),outeronly=False,largestonly=False)")
|
||||
FreeCADGui.doCommand("Part.show(s1)")
|
||||
FreeCADGui.doCommand("s2 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(1,0,0),outeronly=False,largestonly=False)")
|
||||
FreeCADGui.doCommand("Part.show(s2)")
|
||||
FreeCADGui.doCommand("s3 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(0,1,0),outeronly=False,largestonly=False)")
|
||||
FreeCADGui.doCommand("Part.show(s3)")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
FreeCADGui.addCommand('Arch_Equipment',Arch_Equipment())
|
||||
#FreeCADGui.addCommand('Arch_3Views', Arch_3Views())
|
||||
FreeCADGui.addCommand('Arch_Equipment',Arch_Equipment())
|
||||
@@ -28,6 +28,7 @@ from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
@@ -776,43 +777,6 @@ class BIM_Library_TaskPanel:
|
||||
)
|
||||
)
|
||||
|
||||
def getOnlineContentsWEB(self, url):
|
||||
"""Returns a dirs,files pair representing files found from a github url. OBSOLETE"""
|
||||
|
||||
# obsolete code - now using getOnlineContentsAPI
|
||||
import urllib.request
|
||||
result = {}
|
||||
u = urllib.request.urlopen(url)
|
||||
if u:
|
||||
p = u.read()
|
||||
if sys.version_info.major >= 3:
|
||||
p = str(p)
|
||||
dirs = re.findall(r"<.*?octicon-file-directory.*?href.*?>(.*?)</a>", p)
|
||||
files = re.findall(r'<.*?octicon-file".*?href.*?>(.*?)</a>', p)
|
||||
nfiles = []
|
||||
for f in files:
|
||||
for ft in self.getFilters():
|
||||
if f.endswith(ft[1:]):
|
||||
nfiles.append(f)
|
||||
break
|
||||
files = nfiles
|
||||
for d in dirs:
|
||||
# <spans>
|
||||
if "</span" in d:
|
||||
d1 = re.findall(r"<span.*?>(.*?)<", d)
|
||||
d2 = re.findall(r"</span>(.*?)$", d)
|
||||
if d1 and d2:
|
||||
d = d1[0] + "/" + d2[0]
|
||||
r = self.getOnlineContentsWEB(url + "/" + d.replace(" ", "%20"))
|
||||
result[d] = r
|
||||
for f in files:
|
||||
result[f] = f
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
translate("BIM", "Cannot open URL") + ":" + url + "\n"
|
||||
)
|
||||
return result
|
||||
|
||||
def getOnlineContentsAPI(self, url):
|
||||
"""same as getOnlineContents but uses github API (faster)"""
|
||||
|
||||
@@ -906,8 +870,6 @@ class BIM_Library_TaskPanel:
|
||||
def writeOfflineLib():
|
||||
if USE_API:
|
||||
rootfiles = self.getOnlineContentsAPI(LIBRARYURL)
|
||||
else:
|
||||
rootfiles = self.getOnlineContentsWEB(LIBRARYURL)
|
||||
if rootfiles:
|
||||
templibfile = os.path.join(TEMPLIBPATH, LIBINDEXFILE)
|
||||
os.makedirs(TEMPLIBPATH, exist_ok=True)
|
||||
|
||||
@@ -48,6 +48,7 @@ class BIM_Unclone:
|
||||
return v
|
||||
|
||||
def Activated(self):
|
||||
import Arch
|
||||
import Draft
|
||||
|
||||
# get selected object and face
|
||||
|
||||
Reference in New Issue
Block a user