How to trigger an event when the Transform tool opens/exits?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
freedman
Veteran
Posts: 3442
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

How to trigger an event when the Transform tool opens/exits?

Post by freedman »

I know how to get a connection on a property change, this code from ChrisG:

Code: Select all

class DocObs:
	def slotChangedObject(self, obj, prop):
		print("slotChangedObject : {}-{} = {}".format(obj, prop, getattr(obj, prop)))

	def slotBeforeChangeObject(self, obj, prop):
		print("slotBeforeChangeObject : {}-{} = {}".format(obj, prop, getattr(obj, prop)))
do = DocObs()
App.addDocumentObserver(do)
# App.removeDocumentObserver(do)
Anyone have code for detecting when the Transform tool opens/closes?
Thanks
Last edited by freedman on Fri Jan 28, 2022 10:11 pm, edited 3 times in total.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: How to trigger an event when transform exits?

Post by TheMarkster »

Check if the property being changed is the Placement property? You would trigger the observer whether it was editing in the property view, placement task, or with the dragger, but that shouldn't matter unless you specifically need to know only with the dragger dialog exits.
freedman
Veteran
Posts: 3442
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: How to trigger an event when transform exits?

Post by freedman »

The "dragger", that's the key word I needed. I found this so it might get me what I need. I want specifically when the dragger enters/exits so I can start/stop simulations and update my custom placement.
https://forum.freecadweb.org/viewtopic. ... er#p509610
Thanks
freedman
Veteran
Posts: 3442
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: How to trigger an event when transform exits?

Post by freedman »

I still haven't figured out how to do this. The Transform tool isn't active all the time, it might not even be activated, how does one find the event of something like that.
Thanks
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: How to trigger an event when the Transform tool opens/exits?

Post by TheMarkster »

I looked at the link you gave. It looks like you have to create your own dragger for that callback to work. Maybe somebody who knows more on this subject can suggest a way to do it.
freedman
Veteran
Posts: 3442
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: How to trigger an event when the Transform tool opens/exits?

Post by freedman »

For others searching, this looks helpful:
https://forum.freecadweb.org/viewtopic. ... 9&start=10
Post Reply