-
Notifications
You must be signed in to change notification settings - Fork 3
/
legify-technic-pin.FCMacro
67 lines (46 loc) · 1.96 KB
/
legify-technic-pin.FCMacro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# 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:
Console.PrintMessage("No selection!\n")
dialog = QMessageBox(QMessageBox.Warning, 'No selection!', "Please select a Body and Datum Line!")
dialog.setWindowModality(Qt.ApplicationModal)
dialog.exec_()
exit(1)
if not isinstance(selection, list) or len(selection) < 2:
Console.PrintMessage("Only one item selected!\n")
dialog = QMessageBox(QMessageBox.Warning, 'Only one item selected!', "Please select a Body and Datum Line!")
dialog.setWindowModality(Qt.ApplicationModal)
dialog.exec_()
exit(1)
if not selection[0]:
Console.PrintMessage("No selected Body!\n")
dialog = QMessageBox(QMessageBox.Warning, 'No selected Body!', "Please select a Body and Datum Line!")
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!', "Please select a Body and 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")