Arch: Misc bullet-proofing

This commit is contained in:
Yorik van Havre
2022-03-24 09:39:43 +01:00
parent ad95908b88
commit 8cd345186a
2 changed files with 9 additions and 4 deletions

View File

@@ -755,14 +755,14 @@ class ViewProviderBuildingPart:
if hasattr(vobj,"LineWidth"):
self.dst.lineWidth = vobj.LineWidth
elif prop == "FontName":
if hasattr(vobj,"FontName"):
if hasattr(vobj,"FontName") and hasattr(self,"fon"):
if vobj.FontName:
if sys.version_info.major < 3:
self.fon.name = vobj.FontName.encode("utf8")
else:
self.fon.name = vobj.FontName
elif prop in ["FontSize","DisplayOffset","OriginOffset"]:
if hasattr(vobj,"FontSize") and hasattr(vobj,"DisplayOffset") and hasattr(vobj,"OriginOffset"):
if hasattr(vobj,"FontSize") and hasattr(vobj,"DisplayOffset") and hasattr(vobj,"OriginOffset") and hasattr(self,"fon"):
fs = vobj.FontSize.Value
if fs:
self.fon.size = fs
@@ -775,7 +775,7 @@ class ViewProviderBuildingPart:
else:
self.lco.point.setValues([[-fs,0,0],[fs,0,0],[0,-fs,0],[0,fs,0],[0,0,-fs],[0,0,fs]])
elif prop in ["OverrideUnit","ShowUnit","ShowLevel","ShowLabel"]:
if hasattr(vobj,"OverrideUnit") and hasattr(vobj,"ShowUnit") and hasattr(vobj,"ShowLevel") and hasattr(vobj,"ShowLabel"):
if hasattr(vobj,"OverrideUnit") and hasattr(vobj,"ShowUnit") and hasattr(vobj,"ShowLevel") and hasattr(vobj,"ShowLabel") and hasattr(self,"txt"):
z = vobj.Object.Placement.Base.z + vobj.Object.LevelOffset.Value
q = FreeCAD.Units.Quantity(z,FreeCAD.Units.Length)
txt = ""

View File

@@ -78,6 +78,8 @@ def makeRebar(baseobj=None,sketch=None,diameter=None,amount=1,offset=None,name="
if FreeCAD.GuiUp:
sketch.ViewObject.hide()
obj.Host = None
elif baseobj and not sketch:
obj.Shape = baseobj.Shape
if diameter:
obj.Diameter = diameter
else:
@@ -315,13 +317,16 @@ class _Rebar(ArchComponent.Component):
if self.clone(obj):
return
if not obj.Base and ((not obj.Shape) or (not obj.Shape.isNull())):
# let pass without error if we already have a shape
return
if not obj.Base:
FreeCAD.Console.PrintError(
"No Base, return without a rebar shape for {}.\n"
.format(obj.Name)
)
return
if not obj.Base.Shape:
if not hasattr(obj.Base,"Shape") or (not obj.Base.Shape) or obj.Base.Shape.isNull():
FreeCAD.Console.PrintError(
"No Shape in Base, return without a rebar shape for {}.\n"
.format(obj.Name)