Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update StraightRebar.py to work with FreeCAD dev and future 1.0 version #185

Merged
merged 2 commits into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions StraightRebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ def __init__(self, Rebar=None):
self.FaceName = selected_obj.SubElementNames[0]
else:
self.CustomSpacing = Rebar.CustomSpacing
self.FaceName = Rebar.Base.Support[0][1][0]
self.SelectedObj = Rebar.Base.Support[0][0]
if hasattr(Rebar.Base, "Support"):
self.FaceName = Rebar.Base.Support[0][1][0]
self.SelectedObj = Rebar.Base.Support[0][0]
else:
self.FaceName = Rebar.Base.AttachmentSupport[0][1][0]
self.SelectedObj = Rebar.Base.AttachmentSupport[0][0]
self.form = FreeCADGui.PySideUic.loadUi(
str(Path(__file__).with_suffix(".ui"))
)
Expand Down Expand Up @@ -377,7 +381,10 @@ def makeStraightRebar(
"Sketcher::SketchObject", "Sketch"
)
sketch.MapMode = "FlatFace"
sketch.Support = [(structure, facename)]
if hasattr(sketch, "Support"):
sketch.Support = [(structure, facename)]
else:
sketch.AttachmentSupport = [(structure, facename)]
FreeCAD.ActiveDocument.recompute()
sketch.addGeometry(Part.LineSegment(points[0], points[1]), False)
if amount_spacing_check:
Expand Down Expand Up @@ -495,18 +502,33 @@ def editStraightRebar(
):
sketch = Rebar.Base
if structure and facename:
sketch.Support = [(structure, facename)]
if hasattr(sketch, "Support"):
sketch.Support = [(structure, facename)]
else:
sketch.AttachmentSupport = [(structure, facename)]
FreeCAD.ActiveDocument.recompute()
# Check if sketch support is empty.
if not sketch.Support:
showWarning(
"You have checked: 'Remove external geometry of base sketches when "
"needed.'\nTo uncheck: Edit->Preferences->Arch."
)
return
if hasattr(sketch, "Support"):
if not sketch.Support:
showWarning(
"You have checked: 'Remove external geometry of base sketches when "
"needed.'\nTo uncheck: Edit->Preferences->Arch."
)
return
else:
if not sketch.AttachmentSupport:
showWarning(
"You have checked: 'Remove external geometry of base sketches when "
"needed.'\nTo uncheck: Edit->Preferences->BIM."
)
return
# Assigned values
facename = sketch.Support[0][1][0]
structure = sketch.Support[0][0]
if hasattr(sketch, "Support"):
facename = sketch.Support[0][1][0]
structure = sketch.Support[0][0]
else:
facename = sketch.AttachmentSupport[0][1][0]
structure = sketch.AttachmentSupport[0][0]
face = structure.Shape.Faces[getFaceNumber(facename) - 1]
# StructurePRM = getTrueParametersOfStructure(structure)
# Get parameters of the face where sketch of rebar is drawn
Expand Down
Loading