Feature: Automatically select created object

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Posts: 10
Joined: Thu Sep 12, 2019 8:39 am

Feature: Automatically select created object

Postby blasVuwi » Fri Sep 13, 2019 8:07 am

Hello ;)
Is there a way to automatically select an object after creating it? Right now if I create a rectangle, I have to then select it, then hit Wall (in Arch), then select that wall, then resize it. It would be nice if creation operations would automatically select the object they created, wouldn't it?

Code: Select all

OS: Arch Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16131 (Git)
Build type: Release
Branch: makepkg
Hash: 3129ae4296e40ed20e7b3d460b86e6969acbe1c3
Python version: 3.7.4
Qt version: 5.13.0
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Posts: 5206
Joined: Thu Oct 18, 2018 9:18 pm

Re: Feature: Automatically select created object

Postby vocx » Fri Sep 13, 2019 9:34 am

blasVuwi wrote:
Fri Sep 13, 2019 8:07 am
Is there a way to automatically select an object after creating it?...
I am using version 0.19, what you want is possible in my system. I'm not sure if this is a difference between the version, or maybe in your case it doesn't work. I don't remember if in 0.18 I didn't see this behavior.

The Draft code (I assume you mean Draft Rectangle) normally runs a function Draft.select(obj), which selects the object that was just created; so this is normal for most Draft and Arch tools.

https://github.com/FreeCAD/FreeCAD/blob ... ft.py#L789

Code: Select all

def makeRectangle(length, height, placement=None, face=None, support=None):
    if not FreeCAD.ActiveDocument:
        FreeCAD.Console.PrintError("No active document. Aborting\n")
    if placement: typecheck([(placement,FreeCAD.Placement)], "makeRectangle")
    obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Rectangle")

    obj.Length = length
    obj.Height = height
    obj.Support = support
    if face != None:
        obj.MakeFace = face
    if placement: obj.Placement = placement
    if gui:

    return 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.