Python scripting

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!
malinand
Posts: 31
Joined: Sun Aug 02, 2009 2:10 am

Re: Python scripting

Post by malinand »

Hi Werner
There is a little bug - if you have couple ovelapped objects and move cursor from one to enouther the way first one stays highlighted, that object will stay highlighted even when cursor moved away.
It's not necessarily a bug. If the two lines are part of the same SoLineSet node then it's OK. And note, the script was only a quick hack to demonstrate how the mechanism is working.
This I understand and it works correctly. Problem is when there are different objects. Because "mat" is always the last highlitged object, if more then one object was highlighted only last one will be unhighlighted. I changed "mat" to list and append all highlighted nodes to it. It seems working, but don't think it is correct solution because there are many duplicated inputs possible.


There is one more issue - when object changed color during mouse movements sometimes area under the previous cursor location getting wrong color patch. It means that mouse buffer has data from the screen before redraw. It is may be only Windows issue. May be you know how to fix it?

Andrey
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Python scripting

Post by wmayer »

Hi Andrey,

I wouldn't spend too much time on it because in the end we have to write our own Inventor node directly in C++. The Python stuff actually is only a workaround for the time being.

Cheers,
Werner
malinand
Posts: 31
Joined: Sun Aug 02, 2009 2:10 am

Re: Python scripting

Post by malinand »

Hi Werner,
Understood.
I just would like to make sure that issue will not be directly translated into C++.
Here is the fix:

Code: Select all

   node = coin.cast(node,str(node.getTypeId().getName()))
   if (mat == None):
      node.diffuseColor.setValue(1,1,1)
      mat=node
   else:
      if (mat != node):
         mat.diffuseColor.setValue(0,0,0)
         node.diffuseColor.setValue(1,1,1)
         mat=node
Andrey
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Python scripting

Post by wmayer »

Hi Andrey,

I have very good news. I got the Inventor node working as expected. The best is that it worked all the time but we had to use it for lines and points in a bit different way than for faces. However, there are still a few minor issues which I try to fix at the moment.

Cheers,
Werner
Post Reply