Having a wire. Let's place arbitrary point on wire. How to find the edge or vertex on which the point have landed?
My try: https://imgur.com/q9doR2D
[solved] Placing arbitrary point on wire and finding the landing edge
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 101
- Joined: Sun Jul 24, 2022 12:49 pm
[solved] Placing arbitrary point on wire and finding the landing edge
Last edited by stefankorisnik3 on Sun Aug 07, 2022 10:33 pm, edited 1 time in total.
-
- Veteran
- Posts: 3180
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Placing arbitrary point on wire and finding the landing edge
wireshape.distToShape(pointshape) contains the information.
-
- Posts: 101
- Joined: Sun Jul 24, 2022 12:49 pm
-
- Posts: 101
- Joined: Sun Jul 24, 2022 12:49 pm
Re: [solved] Placing arbitrary point on wire and finding the landing edge
Does the wireshape.distToShape(pointshape) returns the number of edge - 1 in the property Edges or in the OrderedEdges as last element in the result array?
-
- Posts: 101
- Joined: Sun Jul 24, 2022 12:49 pm
Re: [solved] Placing arbitrary point on wire and finding the landing edge
And can you let me know what are the values in the result? I get the following result for one interation of givenVertex.Shape.distToShape(c1Shape.Shape) where c1Shape is wire:
Does this means that the landing is on the 27 - 1 edge in the property Edges in the wire?
Also is this consistent do is the 'Edge' always the fourth element of the [-1] of the result?
Code: Select all
(0.0001671146324180315,
[(Vector(46.8228, 0.856581, 151.443), Vector (46.82279999312901, 0.8565813537780497, 151.44316711425782))],
[('Vertex', 0, None, 'Edge', 27, -23.175707956922878)])
Also is this consistent do is the 'Edge' always the fourth element of the [-1] of the result?
-
- Veteran
- Posts: 3180
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: [solved] Placing arbitrary point on wire and finding the landing edge
Code: Select all
box = Part.makeBox(10,10,10)
Part.show(box, 'Box')
p = Part.Plane(App.Vector(6, 6, 6), App.Vector(1,1,1)).toShape()
Part.show(p, "Plane")
wire = box.section(p)
Part.show(wire, 'Wires')
dist, vectors, infos = wire.distToShape(box)
if dist == 0.0:
for i, info in enumerate(infos):
print(f'Box {info[3]}{info[4] + 1} at u = {info[5]} at {vectors[i][1]} | Wire {info[0]}{info[1] + 1}')
else:
print('No intersection\n')