[Is this a BUG] Test if Parent of Part::FeaturePython is a Boolean

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

[Is this a BUG] Test if Parent of Part::FeaturePython is a Boolean

Post by keithsloan52 »

Is there a way to test if the parent of a Part::FeaturePython is a Boolean and if yes, how to test if is the Base or Tool part of the Boolean?

If I look at the inList for the Part::FeaturePython I just see the parent of the Boolean (when the immediate parent is a Boolean).

I note that when scanning a document there appears to be a PartGui::ViewProviderPython object following each Part::FeaturePython object.
Is this a correct conclusion and if yes does it give any clues as to whether the parent is a Boolean?

Thanks
Last edited by keithsloan52 on Sun Oct 11, 2020 5:16 pm, edited 1 time in total.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Test if Parent of Part::FeaturePython is a Boolean

Post by keithsloan52 »

Okay I have resorted to the following code, but see sure there must be a better and more efficient way

Code: Select all

def indexBoolean(list,ln) :
    #print('Length : '+str(ln))
    if ln > 3 :
       #print(range(ln-3))
       for r in range(ln-2) :
          t = list[r].TypeId
          #print(t)
          if t == 'Part::Cut' or t == 'Part::Fuse' or t == 'Part::Common' :
             return r
                
def __init__(self, obj):
     '''Init'''
       if hasattr(obj,'InList') :
          for j in obj.InList :
              if hasattr(j,'OutList') :
                 ln = len(j.OutList)
                 r = indexBoolean(j.OutList,ln)
                 #print('index : '+str(r))
              if r >= 0 :
                 if (ln - r) >= 2 :
                    #print('Tool : '+obj.Label)
                    return   # Okay part of Boolean Let Placement default to 0
       obj.setEditorMode('Placement',2)
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: [Is this a BUG] Test if Parent of Part::FeaturePython is a Boolean

Post by keithsloan52 »

Wondering if this is made harder as a result of a bug?

If an Object is part of a Boolean, should its parent i.e. its InList be the boolean?
What I observe is that is that its InList is the parent of the boolean, so is this a bug?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: [Is this a BUG] Test if Parent of Part::FeaturePython is a Boolean

Post by openBrain »

Impossible to investigate without having at least the sample file you're working on.
Maybe you can find some info in this thread.
Post Reply