Part Geometry Extensions

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Part Geometry Extensions

Post by abdullah »

paullee wrote: Tue May 14, 2019 4:25 pm Hi, your branch compiled in Feb, just go through the steps and it works as expected ! Thanks :)

Testing in Sketcher::SketchObjectPython and have some thought see if you can offer some comment:-


SketchObjectPython - Python generated geometries or User added geometries


Using SketchObjectPython object, the def execute() add some geometries to the object. User can 'manually' add geometry also.

Thinking to add a 'tag' for those geometries added by inherent method of the SketchObjectPython object, to distinguish those added by user.

Not sure what exactly each of below mean, wonder if GeometryBoolExtension or GeometryStringExtension ( "autoGenerated", Geometry ) or ( "userAdded", Geometry )

Thanks for any idea.


- GeometryIntExtension (long int/Py::Long),
- GeometryDoubleExtension (double/Py::Float),
- GeometryBoolExtension(Bool/Py::Boolean),
- GeometryStringExtension(std::string/Py::String).
I am not sure I fully understand your idea. You want to add a geometry extension to an geometry object, so that you can tell whether a geometry was added by the user or by your method?

For this I would use a GeometryBoolExtension, because it is the simplest. You do not need to compare strings.

Code: Select all

geo0.setExtension(Part.GeometryBoolExtension(True,"geocoolness"))
With this, you are creating boolean extension, with name "geocoolness" and set to True.

My advice is to always give extensions a name. You may have several extensions of type boolean.

Some of the geometries will have the boolean extension "geocoolness" and others won't. The ones added by the user won't have it. So to be complete, you have to do two things, check whether there is such an extension and check whether it is set to true.

Extensions are objects. So you have to create them and add them, like in the code above. The syntax is inverse, first you set the property value and second you give it a name. The name is optional because of a different use case, but it is a good practice to always give it a name when using these generic extensions.

Hope this helps. Otherwise ask again ;)

P.S.: I expect to fix the CI for c++11 fully compliant MSVC soon, and be able to merge this in.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Part Geometry Extensions

Post by paullee »

abdullah wrote: Wed May 15, 2019 11:58 am
I am not sure I fully understand your idea. You want to add a geometry extension to an geometry object, so that you can tell whether a geometry was added by the user or by your method?

For this I would use a GeometryBoolExtension, because it is the simplest. You do not need to compare strings.

Code: Select all

geo0.setExtension(Part.GeometryBoolExtension(True,"geocoolness"))
...

Some of the geometries will have the boolean extension "geocoolness" and others won't. The ones added by the user won't have it. So to be complete, you have to do two things, check whether there is such an extension and check whether it is set to true.
Yes, you do - though i find some of my sentence was not complete :)

And thanks for the example and the advice about 2 steps to do which is very useful to understand how it works w/o guessing. I'll try if my idea works or not. :D
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Part Geometry Extensions

Post by abdullah »

paullee wrote: Wed May 15, 2019 2:02 pm And thanks for the example and the advice about 2 steps to do which is very useful to understand how it works w/o guessing. I'll try if my idea works or not. :D
Welcome ;)
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Part Geometry Extensions

Post by paullee »

abdullah wrote: Wed May 15, 2019 11:58 am
Hi it seem furti and easyw-fc are exploring this features in another thread :) Whilst studying this, I have another problem I think just post here or may need another thread. I tried studying some time ago how Sketch Geometry turn into Sketch Shape https://forum.freecadweb.org/viewtopic. ... 10#p266569

With the Part Geometry Extensions feature, (somehow similar to furti's idea), I try say to build Arch Wall based on a Sketch and each 'segment' of wall would read the edge 'Extended Information' say thickness - Say 6 edges - 2 wires form in sketch screencapture.

The problem is, take Arch Wall (or other ArchObject) as example, it would use the Sketch.Shape.Edges (also sortEdge() etc. them), the Shape 'created' / 'connected' by the Sketcher,rather than the Sketch.Geometry (not 'readily usable' before connecting adjacent edges...)

For each edge ArchWall use, I try but find no way 'referencing' it to the Sketch.Geometry[x], in order to read the 'corresponding' 'Part Geometry Extensions'... Hope i express the problem clear enough :)

Thanks for any idea!

Screenshot from 2018-11-03 16-25-51.png
Screenshot from 2018-11-03 16-25-51.png (244.49 KiB) Viewed 1700 times
Screenshot from 2019-06-08 17-18-33.png
Screenshot from 2019-06-08 17-18-33.png (231.55 KiB) Viewed 1698 times
Attachments
Test_ Wire.Sketch.OrderedEdges.OrderedVertexes_rev4_ ArchWall.fcstd
(12.7 KiB) Downloaded 35 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Part Geometry Extensions

Post by abdullah »

paullee wrote: Sat Jun 08, 2019 9:18 am For each edge ArchWall use, I try but find no way 'referencing' it to the Sketch.Geometry[x], in order to read the 'corresponding' 'Part Geometry Extensions'... Hope i express the problem clear enough :)
In the stock FreeCAD, I think the answer is that there is no deterministic way of referencing the wire/edges to geometric elements.

The solver interface is the one that is called to convert the Part Geometry into a wire.

TopoShape Sketch::toShape(void) const

There are many possible solutions to map them, but all of them require adding more functionality to FreeCAD.

For example, this function could be made to store a shape index as a geometry extension. However, there are other related problems that could condition which is the right solution.

First, let's wait to the Geometry Extensions be merged. Then, at some point, I would like to review Realthunder's Sketcher work, which if I remember correctly has worked one aspect of this mapping.

So, summarising, it is not possible ATM to work with the wires and get the corresponding geometry extension information. :(
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Part Geometry Extensions

Post by paullee »

Thanks for the advice.

I somehow try a hard way to compare the 'geometry' between the 'sketcher created wire/edge' to the sketch 'internal geometry' but not working - isPartner(), isEqual(), isSame()....

All return False...?


Maybe just wait as you says :)

Code: Select all

>>> sse0=s.Shape.Edges[0]
>>> sse1=s.Shape.Edges[1]
>>> sse2=s.Shape.Edges[2]
>>> sse3=s.Shape.Edges[3]
>>> sse4=s.Shape.Edges[4]
>>> sse5=s.Shape.Edges[5]

>>> sse0
<Edge object at 0x5583ba4eec40>
>>> sse1
<Edge object at 0x5583ba79e750>
>>> sse2
<Edge object at 0x5583ba79da20>
>>> sse3
<Edge object at 0x5583ba159b90>
>>> sse4
<Edge object at 0x5583b6ee10d0>
>>> sse5
<Edge object at 0x5583b6f42290>


>>> sse0.Vertexes[0].Point
Vector (1968.3749989999994, 795.9012460000001, 0.0)

>>> sse0.Vertexes[1].Point
Vector (3226.933349, 1492.1560060000002, 0.0)

>>> sse1.Vertexes[1].Point
Vector (1968.3749989999994, 795.9012460000001, 0.0)
>>> sse1.Vertexes[0].Point
Vector (1109.6116940000002, 1995.969728, 0.0)
>>> sse2.Vertexes[0].Point
Vector (1109.6116940000002, 1995.969728, 0.0)
>>> sse2.Vertexes[1].Point
Vector (0.0, 0.0, 0.0)
>>> 
>>> 
>>> sse3.Vertexes[0].Point
Vector (3418.472412, 1288.901001, 0.0)
>>> sse3.Vertexes[1].Point
Vector (4395.783691, 712.869812, 0.0)
>>> sse4.Vertexes[0].Point
Vector (4395.783691, 712.869812, 0.0)
>>> sse4.Vertexes[1].Point
Vector (4868.258789, 1049.427368, 0.0)
>>> sse5.Vertexes[0].Point
Vector (4868.258789, 1049.427368, 0.0)
>>> sse5.Vertexes[1].Point
Vector (5670.819824, 253.339249, 0.0)

>>> s.Geometry[2]
<Line segment (1968.37,795.901,0) (3226.93,1492.16,0) >
>>> sg2=s.Geometry[2]

>>> plsg2=Part.LineSegment(sg2)

>>> eplsg2=plsg2.toShape()
>>> sse0.isSame(eplsg2)
False
>>> sse0.isEqual(eplsg2)
False
>>> sse0.isPartner(eplsg2)
False


>>> eplsg2.Vertexes[0].Point
Vector (1968.374998999999, 795.901246, 0.0)
>>> eplsg2.Vertexes[1].Point
Vector (3226.933349, 1492.156006, 0.0)


paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Part Geometry Extensions

Post by paullee »

Hi, whilst waiting this be merged, it is noted there is below property in the Scripted Object wiki

- Part::PropertyGeometryList

Haven't tried, just wondering if this Extension is good for Sketcher only, or all Geometries in whatever objects / WBs enjoy the extended support?


Thanks.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Part Geometry Extensions

Post by abdullah »

paullee wrote: Mon Jul 01, 2019 6:05 am Hi, whilst waiting this be merged, it is noted there is below property in the Scripted Object wiki

- Part::PropertyGeometryList

Haven't tried, just wondering if this Extension is good for Sketcher only, or all Geometries in whatever objects / WBs enjoy the extended support?


Thanks.
Only Sketcher and Part:FeatureGeometrySet. The latter I do not know if it is used anywhere by the FreeCAD GUI.

EDIT: BTW, it is not an extension. It is just a property that contains several geometries.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Part Geometry Extensions

Post by paullee »

Thanks for the advice :)
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Part Geometry Extensions

Post by wmayer »

abdullah wrote: Mon Jul 01, 2019 2:22 pm
Yesterday my computer crashed and it will take me some more time to set-up an alternative.
Post Reply