Hi, I am trying to check if selected thing is a line.
>>> k.TypeId
'Part::Part2DObjectPython'
no Type method.
type of element
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 8
- Joined: Thu Mar 19, 2020 7:02 pm
Re: type of element
You need some deeper understanding of the freecad datastructures used. I recommend Part_Module Part_scripting and Topological_data_scripting
Re: type of element
Also use getSelectionEx() function and test SubObjects.
Re: type of element
What line? A Draft Line? A Draft Line is a Python object (scripted objects) that sits on top of a base C++ object, in this case, Part_Part2DObject. Therefore, its TypeId will be this C++ object.Karol Dembiński wrote: ↑Tue Jun 02, 2020 12:07 pm Hi, I am trying to check if selected thing is a line.
The type of a Draft object is specified in the Type attribute of its Proxy.
Code: Select all
print(obj.Proxy.Type)
Code: Select all
Draft.getType(obj)
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
-
- Posts: 8
- Joined: Thu Mar 19, 2020 7:02 pm
Re: type of element
Well, yes, I mean Draft object named 'line' and I'm using it's start and end, so I wanted to mak sure it not only has start and and, but also make sure that, what is named "start' and 'end' are indeed what I mean.vocx wrote: ↑Tue Jun 02, 2020 2:56 pmWhat line? A Draft Line? A Draft Line is a Python object (scripted objects) that sits on top of a base C++ object, in this case, Part_Part2DObject. Therefore, its TypeId will be this C++ object.Karol Dembiński wrote: ↑Tue Jun 02, 2020 12:07 pm Hi, I am trying to check if selected thing is a line.
The type of a Draft object is specified in the Type attribute of its Proxy.For convenience, Draft provides a function to get this quickly.Code: Select all
print(obj.Proxy.Type)
Code: Select all
Draft.getType(obj)