[ Feature / Bug Fixed ] - Link of Array Solid Subtraction Do Not Create Openings

A forum dedicated to the Draft, Arch and BIM workbenches development.
paullee
Posts: 1827
Joined: Wed May 04, 2016 3:58 pm

[ Feature / Bug Fixed ] - Link of Array Solid Subtraction Do Not Create Openings

Postby paullee » Tue Nov 12, 2019 5:42 pm

Hi, test 2 scenarios : Link of Array VS LinkArray :-

Link of Array Solid Subtraction in Wall Do Not Create Openings
  1. Create a Solid, make an Array
  2. Create a Link to this Array
  3. Make this Link to the Array a Subtraction to a Wall
  4. No Opening is created

    Expectation: Link of Array of Solid create Openings in Wall
LinkArray of Solid Subtraction in Wall Create Openings as Expected
  1. Create a Solid
  2. Create a LinkArray to this Solid
  3. Make this LinkArray a Subtraction to a Wall
  4. Openings are created as expected
Conceptually, they should have same result.
See if @Realthunder can have a look when there is a gap :)

Thanks.
realthunder wrote: Ping
Screenshot from 2019-11-13 01-37-19.png
Screenshot from 2019-11-13 01-37-19.png (237.71 KiB) Viewed 349 times
Screenshot from 2019-11-13 01-37-23.png
Screenshot from 2019-11-13 01-37-23.png (247.97 KiB) Viewed 349 times
Screenshot from 2019-11-13 01-37-41.png
Screenshot from 2019-11-13 01-37-41.png (251.58 KiB) Viewed 349 times
Screenshot from 2019-11-13 01-37-44.png
Screenshot from 2019-11-13 01-37-44.png (260.66 KiB) Viewed 349 times
Attachments
Test_ Wall-Opening_ LinkArray VS Link of Array.FCStd
(92.58 KiB) Downloaded 5 times
Last edited by paullee on Sat Nov 30, 2019 3:31 am, edited 1 time in total.
realthunder
Posts: 1231
Joined: Tue Jan 03, 2017 10:55 am

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby realthunder » Thu Nov 14, 2019 1:56 pm

Been busy with other stuff, will check soon.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
paullee
Posts: 1827
Joined: Wed May 04, 2016 3:58 pm

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby paullee » Thu Nov 14, 2019 6:24 pm

Thanks !
realthunder
Posts: 1231
Joined: Tue Jan 03, 2017 10:55 am

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby realthunder » Fri Nov 15, 2019 2:56 am

PR submitted here
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
vocx
Posts: 1867
Joined: Thu Oct 18, 2018 9:18 pm

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby vocx » Fri Nov 15, 2019 3:31 am

realthunder wrote:
Fri Nov 15, 2019 2:56 am
PR submitted here
Interesting. This is a change completely in Python.

I saw that you did the same in some other bug report. Can you explain a bit your reasoning?

Basically, you are substituting every test that checks if an object is derived from "Part::Feature" (Part_Feature), to a test that checks if the object has a topological shape (Part::TopoShape).

Code: Select all

if obj.isDerivedFrom("Part::Feature")
# equivalent to
if obj.hasattr(child, 'Shape')
I'm not saying it's wrong, I just want to know if there is any circumstance where this may not be true.

As I understand, the test is done because App::Links aren't derived from Part::Feature, but they still have a Shape. Therefore, it is better to test for the existence of the Shape, and not the type of object. The changes should work also for versions before App::Link because it is assumed that every Part::Feature will also have a Part::TopoShape.
realthunder
Posts: 1231
Joined: Tue Jan 03, 2017 10:55 am

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby realthunder » Fri Nov 15, 2019 3:56 am

vocx wrote:
Fri Nov 15, 2019 3:31 am
I'm not saying it's wrong, I just want to know if there is any circumstance where this may not be true.
There is trick somewhere in PropertyContainerPy to call Part.getShape(obj) if the caller requested an attribute named 'Shape' but the object does not have it. Part.getShape() does not simply return the linked shape, there are quite a few things done there, most obvious one is to transform the linked shape into the placement of the Link. It also supports group, which will generate a compound of its children shapes. So you can use App::Part in Arch as well if you like.

If all the Python code wants is to access the Shape, then replacing isDerivedFrom with hasattr shall be fine. If there are other needs, like trying to access the per face color, then it won't work, for now.

Another thing, Link by default will return the property of the linked object as well, unless the Link has a property with the same name . So with a Link to an Extrusion, will can access its Base simply as Link.Base, while Link.Placement will return Link's own placement. In the case of Arch, I saw it does something special with Extrusion. I didn't know its logic there, so I still keep the isDerivedFrom() checking there just to be safe. It may or may not work for a Link to Extrusion.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
vocx
Posts: 1867
Joined: Thu Oct 18, 2018 9:18 pm

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby vocx » Fri Nov 15, 2019 4:47 am

realthunder wrote:
Fri Nov 15, 2019 3:56 am
... In the case of Arch, I saw it does something special with Extrusion. I didn't know its logic there, so I still keep the isDerivedFrom() checking there just to be safe. It may or may not work for a Link to Extrusion.
Thanks for the explanation.

About the extrusion, do you mean this part in ArchComponent.py?

Code: Select all

            # the base is a Part Extrusion
            elif obj.Base.isDerivedFrom("Part::Extrusion"):
                if obj.Base.Base:
                    base,placement = self.rebase(obj.Base.Base.Shape)
                    extrusion = FreeCAD.Vector(obj.Base.Dir)
                    if extrusion.Length == 0:
                        extrusion = FreeCAD.Vector(0,0,1)
                    else:
                        extrusion = placement.inverse().Rotation.multVec(extrusion)
                    if hasattr(obj.Base,"LengthFwd"):
                        if obj.Base.LengthFwd.Value:
                            extrusion = extrusion.multiply(obj.Base.LengthFwd.Value)
                    if not self.isIdentity(obj.Base.Placement):
                        placement = placement.multiply(obj.Base.Placement)
                    return (base,extrusion,placement)
I think it's maybe to get the right orientation of the extrusion.
realthunder
Posts: 1231
Joined: Tue Jan 03, 2017 10:55 am

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby realthunder » Fri Nov 15, 2019 6:48 am

vocx wrote:
Fri Nov 15, 2019 4:47 am
About the extrusion, do you mean this part in ArchComponent.py?

I think it's maybe to get the right orientation of the extrusion.
Yes, and maybe some other places too. Do you know how to create a sample object making use of this?
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
vocx
Posts: 1867
Joined: Thu Oct 18, 2018 9:18 pm

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby vocx » Fri Nov 15, 2019 8:04 am

realthunder wrote:
Fri Nov 15, 2019 6:48 am
... Do you know how to create a sample object making use of this?
It seems to me that ArchComponent.Component.getExtrusionData() is used by other Arch objects like Arch Wall, specifically ArchWall._Wall.getExtrusionData().

https://github.com/FreeCAD/FreeCAD/blob ... #L815-L819

Code: Select all

    def getExtrusionData(self,obj):

        """returns (shape,extrusion vector,placement) or None"""
        import Part,DraftGeomUtils
        data = ArchComponent.Component.getExtrusionData(self,obj)
        if data:
            if not isinstance(data[0],list):
                # multifuses not considered here
                return data
        length  = obj.Length.Value
I'd create a wall from an extrusion. Yorik would be able to tell if there is something special about this.

1. Switch to the Arch Workbench.
2. Draw a Draft Rectangle on the XY plane.
3. Select the Rectangle, then use Draft Trimex. Press Z so that the extrusion is on the Z direction. Enter any value.
4. Select the Extrusion, then use Arch Wall. The wall is created.

The Extrusion seems to be of the desired type.

Code: Select all

>>> App.ActiveDocument.Extrusion
<Part::PartFeature>
>>> App.ActiveDocument.Extrusion.TypeId
'Part::Extrusion'
realthunder
Posts: 1231
Joined: Tue Jan 03, 2017 10:55 am

Re: [ Feature / Bug ] - Link of Array Solid Subtraction Do Not Create Openings

Postby realthunder » Fri Nov 15, 2019 10:25 am

I scanned through the relevant code, and have a feeling that Link can work here but will require some special handling. I'll leave it as it is for now. If any one wants this, please provide a sample document for me to play around.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal