Skip to content

Commit

Permalink
Merge branch 'dev_4_0'
Browse files Browse the repository at this point in the history
  • Loading branch information
davesrocketshop committed Jan 18, 2025
2 parents c7387a1 + 9027081 commit 2e174a0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Rocket/Exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ class UnsupportedVersion(Exception):
def __init__(self, message="Unknown manufacturer"):
self._message = message


class UnsupportedConfiguration(Exception):

def __init__(self, message="Unsupported configuration"):
self._message = message

6 changes: 6 additions & 0 deletions Rocket/FeatureTransition.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from Rocket.Constants import TYPE_CONE, TYPE_ELLIPTICAL, TYPE_HAACK, TYPE_OGIVE, TYPE_VON_KARMAN, TYPE_PARABOLA, TYPE_PARABOLIC, TYPE_POWER
from Rocket.Constants import STYLE_CAPPED, STYLE_HOLLOW, STYLE_SOLID, STYLE_SOLID_CORE
from Rocket.Constants import STYLE_CAP_SOLID, STYLE_CAP_BAR, STYLE_CAP_CROSS
from Rocket.Constants import FEATURE_INNER_TUBE

from Rocket.events.ComponentChangeEvent import ComponentChangeEvent

Expand Down Expand Up @@ -404,3 +405,8 @@ def execute(self, obj):
self._setShapeHandler()
if self._shapeHandler is not None:
self._shapeHandler.draw()

def eligibleChild(self, childType):
return childType in [
#FEATURE_BODY_TUBE,
FEATURE_INNER_TUBE]
14 changes: 13 additions & 1 deletion Rocket/Importer/Rocksim/ComponentElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from Rocket.Importer.OpenRocket.SaxElement import Element
from Rocket.Constants import LOCATION_PARENT_TOP, LOCATION_PARENT_BOTTOM, LOCATION_BASE
from Rocket.Constants import MATERIAL_TYPE_BULK, MATERIAL_TYPE_SURFACE, MATERIAL_TYPE_LINE
from Rocket.position.AxialMethod import AXIAL_METHOD_MAP
from Rocket.position.AxialMethod import AXIAL_METHOD_MAP, BOTTOM

from Rocket.Utilities import _err

Expand Down Expand Up @@ -85,6 +85,8 @@ def handleEndTag(self, tag, content):
self.onAxialOffset(float(content))
elif _tag == "locationmode":
self.onLocationMode(content)
elif _tag == "radialangle":
self.onAngleOffset(content)
elif _tag == "abientcolor":
self._appearance.AmbientColor = self.parseColor(content)
elif _tag == "diffusecolor":
Expand Down Expand Up @@ -145,6 +147,10 @@ def onAxialOffset(self, content):
if hasattr(self._feature._obj, "AxialOffset"):
self._feature._obj.AxialOffset = content

def onAngleOffset(self, content):
if self._feature is not None and hasattr(self._feature._obj, "AngleOffset"):
self._feature._obj.AngleOffset = FreeCAD.Units.Quantity(content + " rad").Value

def onLocationMode(self, content):
mode = int(content)
if mode == 0:
Expand Down Expand Up @@ -208,6 +214,12 @@ def parseColor(self, value):
def end(self):
self.setMaterial(self._feature, self._material, self._densityType)

if self._feature._obj.AxialMethod == BOTTOM:
if hasattr(self._feature._obj, "Location"):
self._feature._obj.Location = -self._feature._obj.Location
if hasattr(self._feature._obj, "AxialOffset"):
self._feature._obj.AxialOffset = -self._feature._obj.AxialOffset

if hasattr(self._feature._obj.ViewObject, "ShapeAppearance"):
self._feature._obj.ViewObject.ShapeAppearance = self._appearance

Expand Down
3 changes: 1 addition & 2 deletions Rocket/Importer/Rocksim/NoseElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def handleEndTag(self, tag, content):
elif _tag == "shoulderlen":
length = float(content)
self._feature._obj.ShoulderLength = length
if length > 0:
self._feature._obj.Shoulder = True
self._feature._obj.Shoulder = (length > 0)
elif _tag == "constructiontype":
constructionType = int(content)
if constructionType == 0:
Expand Down
5 changes: 4 additions & 1 deletion Rocket/Importer/Rocksim/Rocksim.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def __init__(self, parent, tag, attributes, parentObj, filename, line):
"showgridtypebase", "gridspacing", "gridopacity", "gridcolor", "maxdiawithfins", "maxdiawithoutfins",
"maxlenwithfins", "maxlenwithoutfins", "minxextent", "maxxextent", "calculatedmaxstagedia",
"calculatedstagelen", "sideviewdims", "baseviewdims", "vertviewdims", "name", "stage3parts",
"stage2parts", "stage1parts"]
"stage2parts", "stage1parts", "camerastate", "spritepath", "spriteprefix", "comments", "designer",
"revisions"]

self._feature = makeRocket(makeSustainer=False)
self._stageCount = 1
Expand All @@ -127,6 +128,8 @@ def handleEndTag(self, tag, content):
_tag = tag.lower().strip()
if _tag == "designer":
FreeCAD.ActiveDocument.CreatedBy = content
elif _tag == "comment":
self.onComment(content)
elif _tag == "revision":
pass
elif _tag == "stagecount":
Expand Down
4 changes: 3 additions & 1 deletion Rocket/RocketComponentShapeless.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
from Rocket.Constants import FEATURE_ROCKET, FEATURE_STAGE
from Rocket.Constants import LOCATION_SURFACE, LOCATION_CENTER

from Rocket.Exceptions import UnsupportedConfiguration

from DraftTools import translate

class EditedShape(QObject):
Expand Down Expand Up @@ -672,7 +674,7 @@ def addChildPosition(self, component, index):
.format(component.Proxy.getName(), self.getName()))

if not self.eligibleChild(component.Proxy.Type):
raise Exception(translate("Rocket", "Component: {} not currently compatible with component: {}")
raise UnsupportedConfiguration(translate("Rocket", "Unsupported configuration: {} not currently compatible with component: {}")
.format(component.Proxy.getName(), self.getName()))

self._setChild(index, component)
Expand Down
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<package format="1" xmlns="https://wiki.freecad.org/Package_Metadata">
<name>Rocket</name>
<description>A workbench for designing model rockets.</description>
<version>4.1.0</version>
<date>2025-01-17</date>
<version>4.1.1</version>
<date>2025-01-18</date>
<maintainer email="[email protected]">David Carter</maintainer>
<license file="LICENSE">LGPL-2.1-or-later</license>
<url type="repository" branch="master">https://github.com/davesrocketshop/Rocket</url>
Expand Down

0 comments on commit 2e174a0

Please sign in to comment.