Skip to content

Commit

Permalink
feature: added macro to add technic pin to existing body
Browse files Browse the repository at this point in the history
  • Loading branch information
vectronic committed Feb 21, 2022
1 parent e9eb919 commit 915eb39
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,22 @@ to create parametric models in FreeCAD is quite possibly insane!

## Usage

### Create a new brick model
1. Create a new document
1. Run the `legify-brick.FCMacro`
1. Modify parameters as desired in the popup dialog
1. Click OK
1. Wait for a lot of sketches, constraints, pads, pockets and fillets to be rendered...
1. Admire the resulting beauty!

### Add a technic pin to the face of a body
1. Within the Part Design workbench, create a body.
2. Create a datum point on an existing face representing the centre point of the base of the pin.
3. Create a datum point extended 8mm from the normal to the face representing the centre point of the tip of the pin.
4. Create a datum line supported by the base datum point and the tip datum point in that order.
5. Select the body and select the datum line.
6. Run the `legify-technic-pin.FCMacro`

## TODO

- [ ] Wait for [Linear Pattern bug fix](https://tracker.freecad.org/view.php?id=4781) needed when rendering more than one technic pin
Expand Down
49 changes: 49 additions & 0 deletions legify-technic-pin.FCMacro
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# coding: UTF-8

import sys
import os.path

# get the path of the current python script
current_path = os.path.dirname(os.path.realpath(__file__))

# check if this path belongs to the PYTHONPATH variable and if not add it
if not sys.path.__contains__(str(current_path)):
sys.path.append(str(current_path))

from FreeCAD import Console, Gui, activeDocument
from PySide2.QtWidgets import QMessageBox
from PySide2.QtCore import Qt
from Legify.Common import *

if not Gui.activeDocument():

Console.PrintMessage("No active document!\n")
dialog = QMessageBox(QMessageBox.Warning, 'No active document!', "There is no active document!")
dialog.setWindowModality(Qt.ApplicationModal)
dialog.exec_()

exit(1)

selection = Gui.Selection.getSelection()

if not selection[0]:

Console.PrintMessage("No selected body!\n")
dialog = QMessageBox(QMessageBox.Warning, 'No selected body!', "There is no selected body!")
dialog.setWindowModality(Qt.ApplicationModal)
dialog.exec_()

exit(1)

if not selection[1]:
Console.PrintMessage("No selected datum line!\n")
dialog = QMessageBox(QMessageBox.Warning, 'No selected datum line!', "There is no selected datum line!")
dialog.setWindowModality(Qt.ApplicationModal)
dialog.exec_()

exit(1)

render_pin('Pin', selection[1], selection[0], activeDocument())

Gui.activeDocument().activeView().viewAxonometric()
Gui.SendMsgToActiveView("ViewFit")

0 comments on commit 915eb39

Please sign in to comment.