[Solved] Skip excution for some properties

Need help, or want to share a macro? Post here!
jaisejames
Posts: 280
Joined: Sat Sep 24, 2016 6:51 am

[Solved] Skip excution for some properties

Postby jaisejames » Mon Oct 16, 2017 7:13 am

I having some code like below. I want to skip obj execution on change Property like "NomenclatureofWall" because it is holding some text for identification, example "back wall", "Garden side wall" etc. Because setting this text cause entire model unresponsive some seconds.

Code: Select all

class Wall:

 def __init__(self,obj):
   obj.Proxy = self
   obj.addProperty("App::PropertyFloat","LengthofWall")
   obj.addProperty("App::PropertyString","NomenclatureofWall")
   
Last edited by jaisejames on Mon Oct 23, 2017 8:34 am, edited 1 time in total.
User avatar
microelly2
Posts: 4410
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Skip excution for some properties

Postby microelly2 » Mon Oct 16, 2017 7:28 am

You can set a flag when a property is changed you want to ignore it during execute

Code: Select all

	def onChanged(self, fp, prop):
		print ("onChanged",prop)
		if prop=="Size" or prop in ["NomenclatureofWall","n2","e1","e2","e3"]:
			set a flag ....

wmayer
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: Skip excution for some properties

Postby wmayer » Mon Oct 16, 2017 7:37 am

When adding a property you can mark it as output property. This way it won't mark the feature as touched when changing it.

Code: Select all

obj.addProperty("App::PropertyString","NomenclatureofWall","","",8)
Here you can find the different property types: https://github.com/FreeCAD/FreeCAD/blob ... iner.h#L42
jaisejames
Posts: 280
Joined: Sat Sep 24, 2016 6:51 am

Re: Skip excution for some properties

Postby jaisejames » Mon Oct 16, 2017 8:47 am

Thank you all for very quick support.

One for help. I created PropertyLinkList like below code

Code: Select all

for i, sub in enumerate(obj.Objects):
  obj.addProperty('App::PropertyLinkList', "DoorList%d" % i, .....)
  obj.addProperty('App::PropertyFloatList', "DoorPosition%d" % i, .....)
 
based on
https://forum.freecadweb.org/viewtopic.php?f=22&t=23735

Onchange, newly created items/list is coming in bottom of property editor. Now I click another object, then click on object property will sort it properly. Any method to refresh property editor is available without clicking.
User avatar
yorik
Site Admin
Posts: 11552
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: [Solved] Skip excution for some properties

Postby yorik » Mon Oct 23, 2017 7:56 pm

wmayer wrote:
Mon Oct 16, 2017 7:37 am
When adding a property you can mark it as output property. This way it won't mark the feature as touched when changing it.
One more for my "things I still didn't know in FreeCAD" list :)