Skip to content

Commit

Permalink
Merge pull request #7 from vectronic/dev
Browse files Browse the repository at this point in the history
feat: added macro to add technic pin to existing body
  • Loading branch information
vectronic authored Feb 21, 2022
2 parents c6ddfba + 915eb39 commit eca59e4
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 491 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Vectronic
Copyright (c) 2022 Vectronic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
358 changes: 354 additions & 4 deletions Legify/Common.py

Large diffs are not rendered by default.

539 changes: 56 additions & 483 deletions Legify/Pins.py

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,32 @@ to create parametric models in FreeCAD is quite possibly insane!

`git clone https://github.com/vectronic/freecad-legify-macros.git`

1. Link the cloned folder and macro file into the FreeCAD macros directory:
1. Link the cloned folder and macro files into the FreeCAD macros directory:

ln -s <absolute path of cloned repository>/legify-brick.FCMacro <absolute path of user preferences folder>/FreeCAD/Macro/
ln -s <absolute path of cloned repository>/Legify <absolute path of user preferences folder>/FreeCAD/Macro/
ln -s <absolute path of cloned repository>/legify-brick.FCMacro <absolute path of user preferences folder>/FreeCAD/Macro/
ln -s <absolute path of cloned repository>/legify-technic-pin.FCMacro <absolute path of user preferences folder>/FreeCAD/Macro/

**NOTE**: On MacOS the typical location for the user preferences folder is `/Users/<username>/Library/Application\ Support`.

## 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 for a lot of sketches, constraints, pads, pockets and fillets to be rendered...
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
10 changes: 10 additions & 0 deletions legify-brick.FCMacro
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# 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
from PySide2.QtWidgets import QMessageBox
from PySide2.QtCore import Qt
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 eca59e4

Please sign in to comment.