FreeCAD WebAssembly development snapshot
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
This commit is contained in:
66
src/Mod/Sketcher/ProfileLib/Hexagon.py
Normal file
66
src/Mod/Sketcher/ProfileLib/Hexagon.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2014 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD, FreeCADGui, Sketcher, Part
|
||||
|
||||
|
||||
__title__ = "Hexagon profile lib"
|
||||
__author__ = "Juergen Riegel"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
App = FreeCAD
|
||||
Gui = FreeCADGui
|
||||
|
||||
|
||||
def makeHexagonSimple(sketchName=None):
|
||||
if not sketchName:
|
||||
sketch = App.ActiveDocument.addObject("Sketcher::SketchObject", "Hexagon")
|
||||
else:
|
||||
sketch = App.ActiveDocument.getObject(sketchName)
|
||||
|
||||
geoList = []
|
||||
geoList.append(Part.LineSegment(App.Vector(-20.00, 34.64, 0), App.Vector(20.00, 34.64, 0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(20.00, 34.64, 0), App.Vector(47.082363, 0.00, 0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(40.00, 0.00, 0), App.Vector(20.00, -34.64, 0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(20.00, -34.64, 0), App.Vector(-20.00, -34.64, 0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(-20.00, -34.64, 0), App.Vector(-40.00, 0.00, 0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(-40.00, 0.00, 0), App.Vector(-20.00, 34.64, 0)))
|
||||
(l1, l2, l3, l4, l5, l6) = sketch.addGeometry(geoList)
|
||||
|
||||
conList = []
|
||||
conList.append(Sketcher.Constraint("Coincident", l1, 2, l2, 1))
|
||||
conList.append(Sketcher.Constraint("Coincident", l2, 2, l3, 1))
|
||||
conList.append(Sketcher.Constraint("Coincident", l3, 2, l4, 1))
|
||||
conList.append(Sketcher.Constraint("Coincident", l4, 2, l5, 1))
|
||||
conList.append(Sketcher.Constraint("Coincident", l5, 2, l6, 1))
|
||||
conList.append(Sketcher.Constraint("Coincident", l6, 2, l1, 1))
|
||||
conList.append(Sketcher.Constraint("Equal", l1, l2))
|
||||
conList.append(Sketcher.Constraint("Equal", l2, l3))
|
||||
conList.append(Sketcher.Constraint("Equal", l3, l4))
|
||||
conList.append(Sketcher.Constraint("Equal", l4, l5))
|
||||
conList.append(Sketcher.Constraint("Equal", l5, l6))
|
||||
conList.append(Sketcher.Constraint("Angle", l1, 2, l2, 1, App.Units.Quantity("120.000000 deg")))
|
||||
conList.append(Sketcher.Constraint("Angle", l3, 2, l4, 1, App.Units.Quantity("120.000000 deg")))
|
||||
conList.append(Sketcher.Constraint("Angle", l5, 2, l6, 1, App.Units.Quantity("120.000000 deg")))
|
||||
sketch.addConstraint(conList)
|
||||
return
|
||||
83
src/Mod/Sketcher/ProfileLib/RegularPolygon.py
Normal file
83
src/Mod/Sketcher/ProfileLib/RegularPolygon.py
Normal file
@@ -0,0 +1,83 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2014 Johan Kristensen *
|
||||
# * Copyright (c) 2014 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD, FreeCADGui, Sketcher, Part, math
|
||||
|
||||
|
||||
__title__ = "Regular polygon profile lib"
|
||||
__author__ = "Johan Kristensen"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
App = FreeCAD
|
||||
Gui = FreeCADGui
|
||||
|
||||
|
||||
def makeRegularPolygon(
|
||||
sketch,
|
||||
sides,
|
||||
centerPoint=App.Vector(0, 0, 0),
|
||||
firstCornerPoint=App.Vector(-20.00, 34.64, 0),
|
||||
construction=False,
|
||||
):
|
||||
|
||||
if not sketch:
|
||||
App.Console.PrintError("No sketch specified in 'makeRegularPolygon'")
|
||||
return
|
||||
if sides < 3:
|
||||
App.Console.PrintError("Number of sides must be at least 3 in 'makeRegularPolygon'")
|
||||
return
|
||||
|
||||
diffVec = firstCornerPoint - centerPoint
|
||||
diffVec.z = 0
|
||||
angular_diff = 2 * math.pi / sides
|
||||
pointList = []
|
||||
for i in range(0, sides):
|
||||
cos_v = math.cos(angular_diff * i)
|
||||
sin_v = math.sin(angular_diff * i)
|
||||
pointList.append(
|
||||
centerPoint
|
||||
+ App.Vector(
|
||||
cos_v * diffVec.x - sin_v * diffVec.y, cos_v * diffVec.y + sin_v * diffVec.x, 0
|
||||
)
|
||||
)
|
||||
|
||||
geoList = []
|
||||
for i in range(0, sides - 1):
|
||||
geoList.append(Part.LineSegment(pointList[i], pointList[i + 1]))
|
||||
geoList.append(Part.LineSegment(pointList[sides - 1], pointList[0]))
|
||||
geoList.append(Part.Circle(centerPoint, App.Vector(0, 0, 1), diffVec.Length))
|
||||
geoIndices = sketch.addGeometry(geoList, construction)
|
||||
|
||||
sketch.setConstruction(geoIndices[-1], True)
|
||||
|
||||
conList = []
|
||||
for i in range(0, sides - 1):
|
||||
conList.append(Sketcher.Constraint("Coincident", geoIndices[i], 2, geoIndices[i + 1], 1))
|
||||
conList.append(Sketcher.Constraint("Coincident", geoIndices[sides - 1], 2, geoIndices[0], 1))
|
||||
for i in range(0, sides - 1):
|
||||
conList.append(Sketcher.Constraint("Equal", geoIndices[0], geoIndices[i + 1]))
|
||||
for i in range(0, sides):
|
||||
conList.append(Sketcher.Constraint("PointOnObject", geoIndices[i], 2, geoIndices[-1]))
|
||||
sketch.addConstraint(conList)
|
||||
return
|
||||
1
src/Mod/Sketcher/ProfileLib/__init__.py
Normal file
1
src/Mod/Sketcher/ProfileLib/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
Reference in New Issue
Block a user