Skip to content

Commit 4fbccf5

Browse files
committed
Some reworks of AIRCAPs contributions, updated version and documentation
1 parent 518d55e commit 4fbccf5

9 files changed

+60
-55
lines changed

CurvedArray.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -190,23 +190,19 @@ def execute(self, prop):
190190
self.makeRibs(prop)
191191
return
192192

193-
def onChanged(self, fp, prop):
194-
proplist = ["Base", "Hullcurves", "Axis", "Items", "Positions", "OffsetStart", "OffsetEnd", "Twist", "Surface", "Solid", "Distribution", "DistributionReverse"]
195-
for p in proplist:
196-
if not hasattr(fp, p):
197-
return
198-
CurvedShapes.addObjectProperty(fp, "App::PropertyInteger", "LoftMaxDegree", "CurvedArray", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents
199-
200-
if prop in proplist:
201-
if "Positions" in prop and len(fp.Positions) != 0:
202-
setattr(fp,"Items",str(len(fp.Positions)))
203-
outOfBounds = False
204-
for p in fp.Positions:
205-
if (p < 0.0 or p > 1.0):
206-
outOfBounds = True
207-
break
208-
if outOfBounds:
209-
FreeCAD.Console.PrintWarning("Some positions are out of bounds, should all be between 0.0 and 1.0, inclusive\n")
193+
def onChanged(self, fp, prop):
194+
if not hasattr(fp, 'LoftMaxDegree'):
195+
CurvedShapes.addObjectProperty(fp, "App::PropertyInteger", "LoftMaxDegree", "CurvedPathArray", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents
196+
197+
if "Positions" in prop and len(fp.Positions) != 0:
198+
setattr(fp,"Items",str(len(fp.Positions)))
199+
outOfBounds = False
200+
for p in fp.Positions:
201+
if (p < 0.0 or p > 1.0):
202+
outOfBounds = True
203+
break
204+
if outOfBounds:
205+
FreeCAD.Console.PrintWarning("Some positions are out of bounds, should all be between 0.0 and 1.0, inclusive\n")
210206

211207
#background compatibility
212208
CurvedArrayWorker = CurvedArray

CurvedPathArray.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,8 @@ def execute(self, prop):
182182
return
183183

184184
def onChanged(self, fp, prop):
185-
proplist = ["Base", "Hullcurves", "Path", "Items", "OffsetStart", "OffsetEnd", "Twist", "Surface", "Solid", "ScaleX", "ScaleY", "ScaleZ"]
186-
for p in proplist:
187-
if not hasattr(fp, p):
188-
return
189-
CurvedShapes.addObjectProperty(obj,"App::PropertyInteger", "LoftMaxDegree", "CurvedPathArray", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents
185+
if not hasattr(fp, 'LoftMaxDegree'):
186+
CurvedShapes.addObjectProperty(fp, "App::PropertyInteger", "LoftMaxDegree", "CurvedPathArray", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents
190187

191188
#background compatibility
192189
CurvedPathArrayWorker = CurvedPathArray

CurvedSegment.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ def execute(self, fp):
101101
self.update = True
102102

103103

104-
def onChanged(self, fp, prop):
105-
proplist = ["Shape1", "Shape2", "Hullcurves", "NormalShape1", "NormalShape2", "Items", "makeSurface", "makeSolid", "InterpolationPoints", "Twist", "TwistReverse", "Distribution", "DistributionReverse"]
106-
for p in proplist:
107-
if not hasattr(fp, p):
108-
return
109-
CurvedShapes.addObjectProperty(fp,"App::PropertyInteger", "LoftMaxDegree", "CurvedSegment", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents
104+
def onChanged(self, fp, prop):
105+
if not hasattr(fp, 'LoftMaxDegree'):
106+
CurvedShapes.addObjectProperty(fp, "App::PropertyInteger", "LoftMaxDegree", "CurvedSegment", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents
107+
110108

111109
def makeRibs(self, fp):
112110
interpolate = False

CurvedShapes.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,11 @@ def makeCurvedArray(Base = None,
297297
Distribution = 'linear',
298298
DistributionReverse = False,
299299
extract=False,
300-
Twists = []):
300+
Twists = [],
301+
LoftMaxDegree=5):
301302
import CurvedArray
302303
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","CurvedArray")
303-
CurvedArray.CurvedArray(obj, Base, Hullcurves, Axis, Items, Position, OffsetStart, OffsetEnd, Twist, Surface, Solid, Distribution, DistributionReverse, False, Twists)
304+
CurvedArray.CurvedArray(obj, Base, Hullcurves, Axis, Items, Position, OffsetStart, OffsetEnd, Twist, Surface, Solid, Distribution, DistributionReverse, False, Twists, LoftMaxDegree)
304305
if FreeCAD.GuiUp:
305306
CurvedArray.CurvedArrayViewProvider(obj.ViewObject)
306307
FreeCAD.ActiveDocument.recompute()
@@ -322,10 +323,11 @@ def makeCurvedPathArray(Base = None,
322323
Surface=False,
323324
Solid=False,
324325
doScale = [True, True, True],
325-
extract=False):
326+
extract=False,
327+
LoftMaxDegree=5):
326328
import CurvedPathArray
327329
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","CurvedPathArray")
328-
CurvedPathArray.CurvedPathArray(obj, Base, Path, Hullcurves, Items, OffsetStart, OffsetEnd, Twist, Surface, Solid, doScale, extract)
330+
CurvedPathArray.CurvedPathArray(obj, Base, Path, Hullcurves, Items, OffsetStart, OffsetEnd, Twist, Surface, Solid, doScale, extract, LoftMaxDegree)
329331
if FreeCAD.GuiUp:
330332
CurvedPathArray.CurvedPathArrayViewProvider(obj.ViewObject)
331333
FreeCAD.ActiveDocument.recompute()
@@ -344,10 +346,11 @@ def makeCurvedSegment(Shape1 = None,
344346
Twist = 0.0,
345347
TwistReverse = False,
346348
Distribution = 'linear',
347-
DistributionReverse = False):
349+
DistributionReverse = False,
350+
LoftMaxDegree=5):
348351
import CurvedSegment
349352
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","CurvedSegment")
350-
CurvedSegment.CurvedSegment(obj, Shape1, Shape2, Hullcurves, NormalShape1, NormalShape2, Items, Surface, Solid, InterpolationPoints, Twist, TwistReverse, Distribution, DistributionReverse)
353+
CurvedSegment.CurvedSegment(obj, Shape1, Shape2, Hullcurves, NormalShape1, NormalShape2, Items, Surface, Solid, InterpolationPoints, Twist, TwistReverse, Distribution, DistributionReverse, LoftMaxDegree)
351354
if FreeCAD.GuiUp:
352355
CurvedSegment.CurvedSegmentViewProvider(obj.ViewObject)
353356
FreeCAD.ActiveDocument.recompute()
@@ -362,10 +365,11 @@ def makeInterpolatedMiddle(Shape1 = None,
362365
Solid=False,
363366
InterpolationPoints=16,
364367
Twist = 0.0,
365-
TwistReverse = False):
368+
TwistReverse = False,
369+
LoftMaxDegree=5):
366370
import InterpolatedMiddle
367371
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","InterpolatedMiddle")
368-
InterpolatedMiddle.InterpolatedMiddle(obj, Shape1, Shape2, NormalShape1, NormalShape2, Surface, Solid, InterpolationPoints, Twist, TwistReverse)
372+
InterpolatedMiddle.InterpolatedMiddle(obj, Shape1, Shape2, NormalShape1, NormalShape2, Surface, Solid, InterpolationPoints, Twist, TwistReverse, LoftMaxDegree)
369373
if FreeCAD.GuiUp:
370374
InterpolatedMiddle.InterpolatedMiddleViewProvider(obj.ViewObject)
371375
FreeCAD.ActiveDocument.recompute()

FlyingWingS800.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def draw_S800():
8181
MiddleProfile = createSketch_MiddleProfile(doc)
8282
MiddleProfile.ViewObject.Visibility = False
8383

84-
MiddlePart1 = CurvedShapes.makeCurvedSegment(SplineFoilMiddle, SplineFoilWingInside, [MiddleProfile], Items=4, Surface=True, Solid=True, Distribution='elliptic', DistributionReverse=True)
84+
MiddlePart1 = CurvedShapes.makeCurvedSegment(SplineFoilMiddle, SplineFoilWingInside, [MiddleProfile], Items=8, Surface=True, Solid=True, Distribution='elliptic', DistributionReverse=True, LoftMaxDegree=3)
8585
MiddlePart1.Label = "MiddlePart1"
8686
MiddlePart1.ViewObject.Visibility = False
8787

@@ -104,8 +104,8 @@ def draw_S800():
104104
doc.recompute()
105105

106106
sketchCutout = doc.addObject('Sketcher::SketchObject', 'sketchCutout')
107-
sketchCutout.addGeometry(Part.LineSegment(Vector (0.0, 400.0, 0.0), Vector (274.99999999950205, 400.0, 0.0)), False)
108-
sketchCutout.addGeometry(Part.LineSegment(Vector (274.99999999950205, 400.0, 0.0), Vector (75.0, 200.0, 0.0)), False)
107+
sketchCutout.addGeometry(Part.LineSegment(Vector (0.0, 400.0, 0.0), Vector (275, 400.0, 0.0)), False)
108+
sketchCutout.addGeometry(Part.LineSegment(Vector (275, 400.0, 0.0), Vector (75.0, 200.0, 0.0)), False)
109109
sketchCutout.addGeometry(Part.LineSegment(Vector (75.0, 200.0, 0.0), Vector (0.0, 200.0, 0.0)), False)
110110
sketchCutout.addGeometry(Part.LineSegment(Vector (0.0, 200.0, 0.0), Vector (0.0, 400.0, 0.0)), False)
111111
sketchCutout.addConstraint(Sketcher.Constraint('PointOnObject', 0, 1, -2))
@@ -121,7 +121,7 @@ def draw_S800():
121121
sketchCutout.addConstraint(Sketcher.Constraint('DistanceY', 2, 2, midLength))
122122
sketchCutout.addConstraint(Sketcher.Constraint('DistanceY', 3, 1, 3, 2, midLength))
123123
sketchCutout.ViewObject.Visibility = False
124-
124+
sketchCutout.Placement.Base.x = -1
125125

126126
cutout = doc.addObject('Part::Extrusion', 'cutout')
127127
cutout.Base = sketchCutout
@@ -164,9 +164,9 @@ def draw_S800():
164164
obj.ViewObject.hide()
165165

166166
WingAndElevon = CompoundTools.Explode.explodeCompound(WingSlice)
167-
Wing1 = WingAndElevon[0].Group[0]
167+
Wing1 = WingAndElevon[0].Group[1]
168168
Wing1.Label = "Wing1"
169-
ElevonLeft = WingAndElevon[0].Group[1]
169+
ElevonLeft = WingAndElevon[0].Group[0]
170170
ElevonLeft.Label = "ElevonLeft"
171171

172172

InterpolatedMiddle.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,10 @@ def execute(self, fp):
6969

7070

7171
def onChanged(self, fp, prop):
72-
proplist = ["Shape1", "Shape2", "NormalShape1", "NormalShape2", "makeSurface", "makeSolid", "InterpolationPoints", "Twist", "TwistReverse"]
73-
for p in proplist:
74-
if not hasattr(fp, p):
75-
return
76-
CurvedShapes.addObjectProperty(fp,"App::PropertyInteger", "LoftMaxDegree", "InterpolatedMiddle", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents)
77-
72+
if not hasattr(fp, 'LoftMaxDegree'):
73+
CurvedShapes.addObjectProperty(fp, "App::PropertyInteger", "LoftMaxDegree", "InterpolatedMiddle", "Max Degree for Surface or Solid", init_val=5) # backwards compatibility - this upgrades older documents
74+
75+
7876
def makeRibs(self, fp):
7977
interpolate = False
8078
if len(fp.Shape1.Shape.Edges) != len(fp.Shape2.Shape.Edges):
@@ -176,11 +174,15 @@ def Activated(self):
176174
FreeCADGui.doCommand("import CurvedShapes")
177175

178176
selection = FreeCADGui.Selection.getSelectionEx()
179-
for sel in selection:
180-
if sel == selection[0]:
181-
FreeCADGui.doCommand("shape1 = FreeCAD.ActiveDocument.getObject('%s')"%(selection[0].ObjectName))
182-
elif sel == selection[1]:
183-
FreeCADGui.doCommand("shape2 = FreeCAD.ActiveDocument.getObject('%s')"%(selection[1].ObjectName))
177+
if len(selection) < 1:
178+
FreeCADGui.doCommand('shape1 = None')
179+
else:
180+
FreeCADGui.doCommand("shape1 = FreeCAD.ActiveDocument.getObject('%s')"%(selection[0].ObjectName))
181+
182+
if len(selection) < 2:
183+
FreeCADGui.doCommand('shape2 = None')
184+
else:
185+
FreeCADGui.doCommand("shape2 = FreeCAD.ActiveDocument.getObject('%s')"%(selection[1].ObjectName))
184186

185187
FreeCADGui.doCommand("CurvedShapes.makeInterpolatedMiddle(shape1, shape2, Surface=True, Solid=False)")
186188
FreeCAD.ActiveDocument.recompute()

LIESMICH.md

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Zuerst das Basisobjekt auswählen, danach die Hüllkurven. Dann ein Curved Array
4242
- Solid: Einen Festkörper erstellen (funktioniert nur, wenn Base eine geschlossene Form ist)
4343
- Distribution: Algorithmus zur Berechnung der Distanz zwischen den Elementen. Default ist 'linear'. Weitere Möglichkeiten: parabolic (x²), x³, sinusoidal, asinusoidal, elliptic
4444
- DistributionReverse: Kehrt die Richtung des Distrubution Algorithmus um
45+
- LoftMaxDegree: Gradzahl für die Erstellung von Oberflächen und Festkörpern.
4546

4647
Distribution Linear
4748
![Linear](Examples/CurvedArrayLinear.jpg)
@@ -95,6 +96,7 @@ Zuerst das Basisobjekt auswählen, danach den Pfad, und zum Schluss die Hüllkur
9596
- ScaleX: Hullcurves können in X Richtung skalieren
9697
- ScaleY: Hullcurves können in Y Richtung skalieren
9798
- ScaleZ: Hullcurves können in Z Richtung skalieren
99+
- LoftMaxDegree: Gradzahl für die Erstellung von Oberflächen und Festkörpern.
98100

99101
Wenn Hullcurves verwendet werden und die Objekte nicht rechtwinklig zum Path angeordnet sind, muss evtl. die Skaliereng in eine Raumrichtung ausgeschaltet werden, in dem ScaleX, ScaleY oder ScaleZ auf false gesetzt wird.
100102

@@ -121,6 +123,7 @@ Zuerst zwei 2D Kurven auswählen, dann optional noch eine oder mehrere Hüllkurv
121123
- TwistReverse: wenn True, wird die Drehrichtung geändert
122124
- Distribution: Algorithmus zur Berechnung der Distanz zwischen den Elementen. Default ist 'linear'. Weitere Möglichkeiten: parabolic (x²), x³, sinusoidal, elliptic
123125
- DistributionReverse: Kehrt die Richtung des Distrubution Algorithmus um
126+
- LoftMaxDegree: Gradzahl für die Erstellung von Oberflächen und Festkörpern.
124127

125128
### ![](./Resources/icons/CornerShape.svg) Interpolated Middle
126129
Interpoliert eine 2D Kurve in der Mitte zwischen zwei 2D Kurven. Es kann ein Verbinder mit einem Knick zwischen den den Kurven generiert werden.
@@ -140,6 +143,7 @@ Interpoliert eine 2D Kurve in der Mitte zwischen zwei 2D Kurven. Es kann ein Ver
140143
- TwistReverse: wenn True, wird die Drehrichtung geändert
141144
- Distribution: Algorithmus zur Berechnung der Distanz zwischen den Elementen. Default ist 'linear'. Weitere Möglichkeiten: parabolic (x²), x³, sinusoidal, elliptic
142145
- DistributionReverse: Kehrt die Richtung des Distrubution Algorithmus um
146+
- LoftMaxDegree: Gradzahl für die Erstellung von Oberflächen und Festkörpern.
143147

144148

145149
### ![](./Resources/icons/surfaceCut.svg) Surface Cut

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The first curve that you select for CurvedArray creation will be the item that i
4949
- Solid: make a solid if Base is a closed shape
5050
- Distribution: Algorithm for distance between array elements. Default is 'linear'. Also selectable: parabolic (x²), x³, sinusoidal, asinusoidal, elliptic
5151
- DistributionReverse: Reverses the direction of the Distribution algorithm
52+
- LoftMaxDegree: degree for surface or solid creation. Play with this parameter if your surface or solid looks distorted
5253

5354
Distribution Linear
5455
![Linear](Examples/CurvedArrayLinear.jpg)
@@ -102,6 +103,7 @@ The first curve that you select for Curved Path Array creation will be the base
102103
- ScaleX: Scale by hullcurves in X direction
103104
- ScaleY: Scale by hullcurves in Y direction
104105
- ScaleZ: Scale by hullcurves in Z direction
106+
- LoftMaxDegree: degree for surface or solid creation. Play with this parameter if your surface or solid looks distorted
105107

106108
The parameters ScaleX, ScaleY and ScaleZ have been added because you may want to rescale the items only in one direction, but the hullcurves normally cover 2 or three room directions.
107109

@@ -127,6 +129,7 @@ Select two 2D shapes first. The curved segment will be created between them. If
127129
- TwistReverse: Reverses the rotation of one Shape
128130
- Distribution: Algorithm for distance between array elements. Default is 'linear'. Also selectable: parabolic (x²), x³, sinusoidal, elliptic
129131
- DistributionReverse: Reverses the direction of the Distribution algorithm
132+
- LoftMaxDegree: degree for surface or solid creation. Play with this parameter if your surface or solid looks distorted
130133

131134
### ![CornerShapeIcon](./Resources/icons/CornerShape.svg) Interpolated Middle
132135
Interpolates a 2D shape into the middle between two 2D curves. The base shapes can be connected to a shape with a sharp corner.
@@ -144,6 +147,7 @@ Interpolates a 2D shape into the middle between two 2D curves. The base shapes c
144147
- InterpolationPoints: ignored if Shape1 and Shape2 have the same number of edges and poles. Otherwise all edges will be split (discretized) into this number of points
145148
- Twist: Compensates a rotation between Shape1 and Shape2
146149
- TwistReverse: Reverses the rotation of one Shape
150+
- LoftMaxDegree: degree for surface or solid creation. Play with this parameter if your surface or solid looks distorted
147151

148152

149153
### ![surfaceCutIcon](./Resources/icons/surfaceCut.svg) Surface Cut

package.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<package format="1" xmlns="https://wiki.freecad.org/Package_Metadata">
33
<name>Curved Shapes</name>
44
<description>Create 3D shapes from 2D curves.</description>
5-
<version>1.00.09</version>
6-
<date>2024-04-17</date>
5+
<version>1.00.10</version>
6+
<date>2024-09-20</date>
77
<maintainer email="[email protected]">Christi</maintainer>
88
<license file="LICENSE">LGPL-2.1</license>
99
<url type="repository" branch="master">https://github.com/chbergmann/CurvedShapesWorkbench</url>

0 commit comments

Comments
 (0)