hi
working with script and many times got some bad things:
in some types of objects there are vertexes/vectors of one type, that have members X Y and Z (capital).
But some other types have vertexes of another type and have members x y and z (not capital),
when difference will be fixed for one standard? it is to mach work added to work in one script with different types of objects.
vertexes coordinates

 Veteran
 Posts: 1371
 Joined: Thu Sep 24, 2020 10:31 pm
 Location: Hawaii
 Contact:
Re: vertexes coordinates
Can you give examples of vertices of different types?lagunax wrote: ↑Sat Jun 25, 2022 2:02 pm hi
working with script and many times got some bad things:
in some types of objects there are vertexes/vectors of one type, that have members X Y and Z (capital).
But some other types have vertexes of another type and have members x y and z (not capital),
when difference will be fixed for one standard? it is to mach work added to work in one script with different types of objects.
I have found that vertex.X gives the xcoordinate of the vertex's location and that vector.x is the xcomponent of a vector. They are quite different entities. Perhaps the notation is a reminder that vertex.X is only a getter, while vector.x is a getter and a setter.
Re: vertexes coordinates
it is too long script allready, will try to show in shortest
here in 'vertex1' and 'vertex2' used different case of letters. changing will make error.
this is not only one situation. and this is realy strange. i think tha no metter can you change it or not  it may be used in different ways and searching where to use on or another is a little hard way in big code. also if i have function that can get both types  how can i determine what one to use? determining will add unnessesary code to know what kind of coordinate to use.
in this case i see another one way of overloaded logic of FC. we have vector, we have vertex and etc, all of them have coordinates. if we can change one, why we can't change another? as result we got not unified representation of same parameters and overloaded code. imo
Code: Select all
#in a loop i get face in this way
for face1 in object1.Shape.Faces
for face21 in object1.Shape.Faces
# next in another function i get intersection line with
dts = face1.distToShape(face2)
if dts[0] > 1e7:
return None
else:
return Part.makeLine(dts[1][0][0],dts[1][1][0])
# next in another function i get this for calculations
result=face1.distToShape(edge)
#where edge is returned line frome above Part.makeLine
...
cur_vertex=result[1][1][1]
num_edge=result[2][1][1]
cur_edge=face.Edges[num_edge]
last_vertex=cur_edge.Vertexes[0]
vertex1=Vector(cur_vertex.x,cur_vertex.y,cur_vertex.z)
vertex2=Vector(last_vertex.X,last_vertex.Y,last_vertex.Z)
this is not only one situation. and this is realy strange. i think tha no metter can you change it or not  it may be used in different ways and searching where to use on or another is a little hard way in big code. also if i have function that can get both types  how can i determine what one to use? determining will add unnessesary code to know what kind of coordinate to use.
in this case i see another one way of overloaded logic of FC. we have vector, we have vertex and etc, all of them have coordinates. if we can change one, why we can't change another? as result we got not unified representation of same parameters and overloaded code. imo
Re: vertexes coordinates
You are facing the same comprehension problem again.
A Vertex is a topology entity upon a geometry Vector.
You can create a vector, wherever you want, and build a vertex on this support geometry :
But you can't modify a vertex directly :
This would move the vertex away from its geometry support entity. This is a nonsense.
A Vertex is a topology entity upon a geometry Vector.
You can create a vector, wherever you want, and build a vertex on this support geometry :
Code: Select all
vec = FreeCAD.Vector(10, 20, 30)
vert = Part.Vertex(vec)
Code: Select all
vert.X = 15
# Traceback (most recent call last):
# File "<input>", line 1, in <module>
# AttributeError: Attribute 'X' of object 'TopoShape' is readonly
Re: vertexes coordinates
i do not need to modify them, because i make new object later in code.
but problem stands where i need to use different objects with same function. totaly i need to make different functions only for xXcompatability. if all coordinates was x or all X then i need only one function.
in this case if i will make one function so i need to determine what kind of object i got in args  this is also hard way, becous objects like Vertex have no any ParametersList or Type methods to determine what kind of object i got.
in my script above there is an example of hardness of logic: i just need to get coordinates of vertexes of objects, but when i started work with code ii found that i need to know what kind of object and where i got  in this way i need to look all logic and find from where it can be gotten, also i need to know what object have x and what have X. etc...
finaly i spend mach more time on debugging and making copies of functions for another types of objects only because some have x and other have X.
also i do not need to create vector myself, in my script it will be looking like:
1) determine if gotten point is vector or not  to mach overload, because i need to know what kind of object i got (see above)
2) if it is not vector then get coordinate and make vector from them
it is sometimes hard to make scripts because of situations like this one. it adds realy unneeded work
but problem stands where i need to use different objects with same function. totaly i need to make different functions only for xXcompatability. if all coordinates was x or all X then i need only one function.
in this case if i will make one function so i need to determine what kind of object i got in args  this is also hard way, becous objects like Vertex have no any ParametersList or Type methods to determine what kind of object i got.
in my script above there is an example of hardness of logic: i just need to get coordinates of vertexes of objects, but when i started work with code ii found that i need to know what kind of object and where i got  in this way i need to look all logic and find from where it can be gotten, also i need to know what object have x and what have X. etc...
finaly i spend mach more time on debugging and making copies of functions for another types of objects only because some have x and other have X.
also i do not need to create vector myself, in my script it will be looking like:
1) determine if gotten point is vector or not  to mach overload, because i need to know what kind of object i got (see above)
2) if it is not vector then get coordinate and make vector from them
it is sometimes hard to make scripts because of situations like this one. it adds realy unneeded work
Re: vertexes coordinates
To tell what @Chris_G has told you in a different way:
1) Vertex is a Topology concepts and is a TopoShape
if you type:
Code: Select all
vtx = Part.Vertex(FreeCAD.Vector(10,20,5))
print(vtx.TypeId)
you will see it will print
Code: Select all
Part::TopoShape
Code: Select all
vtx = Part.Vertex(FreeCAD.Vector(10,20,5))
pt = vtx.Point
print(pt)
you will see that it print:
Code: Select all
Vector (10.0, 20.0, 5.0)
and if you do:
Code: Select all
dir(FreeCAD.Vector)
They are different things.
It depends on what the method you are calling will return:
1) a Part.Vertex you have the properties of a Vertex Object so X,Y.Z so uppercase
2) a FreeCAD.Vector same as Base.Vector it has x,y,x properties (lowercase)
Probably some checks in the code will make the job, or just remember to test if the object is returned as an instance of Part.Vertex to simply take his .Point property that will return the Vector so you have always a x,y,z property to work on.
You could not change a Vertex assigning X,Y.,Z properties directly as they are not properties of the "Vertex" that is a TopoShape but are simply exposed taking them to the underlying geometry that is the Vector contained in the Point property of a Vertex
Topology entitiy
Hope I've been clear, if not I apologize
Regards
Carlo D.
EDIT: Sorry for multiple edits, but sometimes I see errors, only in the forum post as characters of the edit windows in my Browser are less readable.
My English and Italian Scripting Guide https://github.com/onekk/freecaddoc.
My Blog: https://onekkmaker.blogspot.com/
To help development see on GitHub Page
For enquiry about customized FC Scripting job PM me.
My Blog: https://onekkmaker.blogspot.com/
To help development see on GitHub Page
For enquiry about customized FC Scripting job PM me.