Edges and faces names

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!
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Edges and faces names

Post by jriegel »

The main mechanism at the moment for the naming is the ordering in the brep structure.
But if you get the shape out of the document:

Code: Select all

s = App.ActiveDocument.Box.Shape
you are on python object level. Her we have no interface for naming. You can guess by using
s.edges[1] will be most likely "ActiveDocument.Box.Edge1".
Stop whining - start coding!
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Edges and faces names

Post by shoogen »

jriegel wrote:The main mechanism at the moment for the naming is the ordering in the brep structure.
Is there (yet) any other then 'the main' mechanism? Are there plans to introduce such?
jriegel wrote:But if you get the shape out of the document:

Code: Select all

s = App.ActiveDocument.Box.Shape
you are on python object level. Her we have no interface for naming. You can guess by using
s.edges[1] will be most likely "ActiveDocument.Box.Edge1".
Numbering in FreeCAD starts with One, whereas indices in pyhton start with zero.

Code: Select all

>>> App.ActiveDocument.Box.Shape.Edge1.isSame(App.ActiveDocument.Box.Shape.Edges[0])
True
And to me this mapping has allways been consistent. And I rely on that in my scripts. like

Code: Select all

    roundedw = wedge.makeFillet(20,wedge.Edges[1:8:2])
    roundedlid = lid.makeFillet(30,lid.Edges[0:8:2])
    roundedlidinner = lidinner.makeFillet(20,lidinner.Edges[0:8:2])
    lid=roundedlid.cut(roundedlidinner)
    lid2=lid.makeFillet(7,lid.Edges[0:1]+lid.Edges[12:19])
Lines 1-3 rely on the Edge order/naming for boxes and wedges. For the last line the Edges where identified in the gui, therefore i need to the naming to be consistend between python and the GUI. And i will need to redo that every time OCC changes the allgoritm;)
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Edges and faces names

Post by wmayer »

you are on python object level. Her we have no interface for naming. You can guess by using
s.edges[1] will be most likely "ActiveDocument.Box.Edge1".
That's wrong! s.Edges[0] is the same as ActiveDocument.Box.Edge1. Note: In the python list we start with the element 0 while on document level we start with 1.
ivanzero
Posts: 30
Joined: Wed Jan 25, 2012 9:35 pm

Re: Edges and faces names

Post by ivanzero »

shoogen
I looked at the script, it looks interesting, but unfortunately does not solve my problem.
Thanks anyway

It seems that I'll only be able to create geometry but not modify it.
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Edges and faces names

Post by jriegel »

Thats right, python start with 0. My fault.

maybe in the futere there is a more sophisticated naming mechanism. But not yet...
Stop whining - start coding!
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Edges and faces names

Post by wmayer »

It seems that I'll only be able to create geometry but not modify it.
The TopoShape class in Python has the method replaceShape(). The argument is a list of tuples. You can use it this way:

Code: Select all

myShape.replaceShape([(subShape1OfmyShape, newShape1), (subShape2OfmyShape, newShape2)])
But note this is a very low-level function. If you have e.g. a box and want to modify a vertex then you must first replace the vertex to change the edges. Then you must replace the edges to change the wire. And finally you must replace the wire to change the face. In general this is a very cumbersome method and I never have seen a good example of this.
ivanzero
Posts: 30
Joined: Wed Jan 25, 2012 9:35 pm

Re: Edges and faces names

Post by ivanzero »

It seems that I'll only be able to create geometry but not modify it.
Warner,
I was not well expressed when I wrote this (Google translate does not translate always the best).

I found one paper, perhaps you have already seen:

International Journal of CAD/CAM
http://www.ijcc.org/

Vol 5
Identification of Topological Entities and Naming Mapping for Parametric CAD Model Exchanges

direct link http://www.ijcc.org/ojs/index.php/ijcc/ ... view/42/37

I hope this will help in your work.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Edges and faces names

Post by wmayer »

No, I didn't know of the paper. Thanks for the link, it looks quite interesting.
montyl
Posts: 19
Joined: Tue Jan 22, 2019 5:08 am

Re: Edges and faces names

Post by montyl »

I found a penny... an Internet search led me to this post and down the rabbit hole I went...

Although it's entirely possible that one or more devs have knowledge of the above mentioned article, I figured I'd post a working link to it since ijcc.org is no longer. Maybe the solution to the topological naming problem is here...

https://www.koreascience.or.kr/article/ ... 36985.page

From the last page of the article:

Code: Select all

5. Conclusions
Persistent naming and naming mapping problems
occur during the exchange of CAD models that have
parametric information. The present study analyzes the
characteristics of the persistent naming problem from
the viewpoint of exchanging CAD models. Based on the
analysis of related works, a persistent naming method
and a naming mapping method are proposed. The
proposed persistent naming method is based on OSI
(object space information) and SN (secondary name).
OSI is used to solve the ambiguity problem that arises
from entity splitting. SN is used to solve the ambiguity
problem that arises from entity merging. The proposed
naming mapping method uses IGM. TGM is a geometric
model generated by a geometric modeling kernel
according to the design history. The design history is in
the form of a feature tree or a macro file, and the
necessary information for naming mapping is retrieved
or calculated from the IGM.
The persistent naming method and naming mapping
method proposed in the present study have been
adopted into a macro parametric translator [17, 18].
Parametric information has been successfully transferred
in an experimental implementation.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Edges and faces names

Post by adrianinsaval »

Wow, that's some necro bumping (if you waited one more month you would have posted in the 10th anniversary of this thread :lol: )... better see:
Topological naming problem
https://forum.freecadweb.org/viewtopic.php?t=27278
https://forum.freecadweb.org/viewtopic.php?f=17&t=58005

we have an implementation (no idea if it used what's described in the article) pending review to get merged supposedly in 3 stages, unfortunately the merge effort has stalled for quite some time, so we don't have even a rough estimate on when this might get merged. In the meantime you could try realthunder's release that has that code among many other changes.
If it's not using the article's method know that unless someone can reasonable prove the method from the article is significantly better than that implementation and then code it himself (or somehow convince someone else to do it, very unlikely) I don't think we are going to see another re implementation of this.
Post Reply