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!
blasVuwi
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)
vocx
Posts: 1403
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")
        return
    if placement: typecheck([(placement,FreeCAD.Placement)], "makeRectangle")
    obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Rectangle")
    _Rectangle(obj)

    obj.Length = length
    obj.Height = height
    obj.Support = support
    if face != None:
        obj.MakeFace = face
    if placement: obj.Placement = placement
    if gui:
        _ViewProviderRectangle(obj.ViewObject)
        formatObject(obj)
        select(obj)

    return obj