Skip to content

Commit

Permalink
#6 OpenRocket import
Browse files Browse the repository at this point in the history
  • Loading branch information
davesrocketshop committed Jan 5, 2023
1 parent 53d4858 commit 5af8023
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion App/FeatureInnerTube.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

from DraftTools import translate

class FeatureInnerTube(ThicknessRingComponent, AxialPositionable, BoxBounded, RadialParent):#, Clusterable - not sure why this is causing errors
class FeatureInnerTube(Clusterable, ThicknessRingComponent, AxialPositionable, BoxBounded, RadialParent):

def __init__(self, obj):
super().__init__(obj)
Expand Down
4 changes: 2 additions & 2 deletions App/Importer/CenteringRingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
__url__ = "https://www.davesrocketshop.com"

from App.Importer.SaxElement import NullElement
from App.Importer.RingComponentElement import RingComponentElement
from App.Importer.RadiusRingComponentElement import RadiusRingComponentElement

from Ui.Commands.CmdBulkhead import makeBulkhead
from Ui.Commands.CmdCenteringRing import makeCenteringRing

class BulkheadElement(RingComponentElement):
class BulkheadElement(RadiusRingComponentElement):

def __init__(self, parent, tag, attributes, parentObj, filename, line):
super().__init__(parent, tag, attributes, parentObj, filename, line)
Expand Down
54 changes: 54 additions & 0 deletions App/Importer/RadiusRingComponentElement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ***************************************************************************
# * Copyright (c) 2021 David Carter <[email protected]> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
"""Provides support for importing Open Rocket files."""

__title__ = "FreeCAD Open Rocket Importer Common Component"
__author__ = "David Carter"
__url__ = "https://www.davesrocketshop.com"

import FreeCAD

from App.Importer.RingComponentElement import RingComponentElement

class RadiusRingComponentElement(RingComponentElement):

def __init__(self, parent, tag, attributes, parentObj, filename, line):
super().__init__(parent, tag, attributes, parentObj, filename, line)

self._knownTags.extend(["instancecount", "instanceseparation"])


def handleEndTag(self, tag, content):
_tag = tag.lower().strip()
if _tag == "instancecount":
self.onInstanceCount(int(content))
elif _tag == "instanceseparation":
self.onInstanceSeparation(FreeCAD.Units.Quantity(content + " m").Value)
else:
super().handleEndTag(tag, content)

def onInstanceCount(self, count):
if hasattr(self._feature._obj, "InstanceCount"):
self._feature._obj.InstanceCount = count

def onInstanceSeparation(self, value):
if hasattr(self._feature._obj, "InstanceSeparation"):
self._feature._obj.InstanceSeparation = value

0 comments on commit 5af8023

Please sign in to comment.