Code: Select all
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods:
* Help 1.0.3
I am just learning getSelectionEx and am experimenting.
Image included. If I select the one labeled 1 I get:
Code: Select all
18:41:12 (Vector (-292.7307434082031, -731.577392578125, 0.0),)
18:41:12 -292.7307434082031
18:41:12 -11.524832200978944
Code: Select all
18:41:12 (Vector (-292.7307434082031, -731.577392578125, 0.0),)
18:41:12 -292.7307434082031
18:41:12 -11.524832200978944
18:42:53 (Vector (-273.8681335449219, -738.897216796875, 0.0),)
18:42:53 -273.8681335449219
18:42:53 -10.782209779377991
Note I only selected the point. Is this a bug? Seems you cannot select just a point if added to the end of a line without problems.18:44:27 Traceback (most recent call last):
File "C:/Users/Owner/AppData/Roaming/FreeCAD/Macro/Get_Line_two.FCMacro", line 9, in <module>
sels[0].SubObjects[0].ShapeType
<class 'IndexError'>: tuple index out of range
Even though the line is not in or part of the selection.
Small test script:
Code: Select all
# -*- coding: utf-8 -*-
import FreeCAD,FreeCADGui
import Draft
import math
from PySide import QtGui
sels = Gui.Selection.getSelectionEx()
sels[0].SubObjects[0].ShapeType
PT = sels[0].SubObjects[0].Point
PX= sels[0].PickedPoints
print(PX)
X1 = PX[0].x
print(PX[0].x)
X1 = X1 * .039370078
print(X1)
I tried combinations of getSelection() also, but could not find an example that worked. Tried:
Code: Select all
# -*- coding: utf-8 -*-
import FreeCAD,FreeCADGui
import Draft
import math
from PySide import QtGui
s = FreeCADGui.Selection.getSelection()
PX=s[0].Shape
print(PX[0].x)
19:27:55 Traceback (most recent call last):
File "C:/Users/Owner/AppData/Roaming/FreeCAD/Macro/Get_single.FCMacro", line 11, in <module>
print(PX[0].x)
<class 'TypeError'>: 'Part.Wire' object is not subscriptable