Projection of Wire on Mesh

Need help, or want to share a macro? Post here!
User avatar
HakanSeven12
Posts: 216
Joined: Wed Feb 06, 2019 10:30 pm

Projection of Wire on Mesh

Postby HakanSeven12 » Thu May 09, 2019 9:12 pm

How can I create a parallel projection of a wire on a mesh surface like this?
(Green line is mesh, red one is projected wire and black one is first wire)

Projection.png
Projection.png (5.58 KiB) Viewed 100 times
Last edited by HakanSeven12 on Sun Jun 09, 2019 10:51 pm, edited 3 times in total.
User avatar
Joel_graff
Posts: 1293
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Projection of Wire on Mesh

Postby Joel_graff » Fri May 10, 2019 3:23 am

@microelly2 can probably answer that one.
microelly2 wrote: ping
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails
jbi
Posts: 45
Joined: Sun Apr 24, 2016 3:28 pm

Re: Projection of Wire on Mesh

Postby jbi » Sat May 11, 2019 8:09 am

maybe a solution would be : Extrude a wire or edge with Part -> convert to mesh via STL -> mesh.intersect(STL)
User avatar
microelly2
Posts: 4247
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Projection of Wire on Mesh

Postby microelly2 » Sat May 11, 2019 2:20 pm

First convert the mesh to a part
than you can apply the makeParallelProjection method to each face and your wire

>>> f=App.ActiveDocument.Box.Shape.Face1

>>> f.makeParallelProjection.__doc__
'Parallel projection of an edge or wire on this shape\nmakeParallelProjection(shape, dir)\n '

>>> f.makePerspectiveProjection.__doc__
'Perspective projection of an edge or wire on this shape\nmakePerspectiveProjection(shape, pnt)\n '

see for more discussion here
https://forum.freecadweb.org/viewtopic.php?t=5360
wmayer
Site Admin
Posts: 14232
Joined: Thu Feb 19, 2009 10:32 am

Re: Projection of Wire on Mesh

Postby wmayer » Tue May 14, 2019 1:24 pm

git commit c60658f3f

Code: Select all

shape = ...
mesh = ...
projectionDir = App.Vector(...)

import MeshPart
import Part
polylines = MeshPart.projectShapeOnMesh(shape, mesh, projectionDir)

for i in polylines:
    Part.show(Part.makePolygon(i))
User avatar
HakanSeven12
Posts: 216
Joined: Wed Feb 06, 2019 10:30 pm

Re: Projection of Wire on Mesh

Postby HakanSeven12 » Tue May 14, 2019 2:42 pm

I will try it when next 0.19_pre build is available :)
Last edited by HakanSeven12 on Sun May 19, 2019 10:16 am, edited 1 time in total.
User avatar
HakanSeven12
Posts: 216
Joined: Wed Feb 06, 2019 10:30 pm

Re: Projection of Wire on Mesh

Postby HakanSeven12 » Sun May 19, 2019 10:15 am

wmayer wrote:
Tue May 14, 2019 1:24 pm
git commit c60658f3f

Code: Select all

shape = ...
mesh = ...
projectionDir = App.Vector(...)

import MeshPart
import Part
polylines = MeshPart.projectShapeOnMesh(shape, mesh, projectionDir)

for i in polylines:
    Part.show(Part.makePolygon(i))
I tried it. If all wire points drop on mesh its create projection wires. But if wire points does not drop on mesh its return empty list.


first.png
first.png (112.9 KiB) Viewed 265 times

second.png
second.png (118.95 KiB) Viewed 265 times
wmayer
Site Admin
Posts: 14232
Joined: Thu Feb 19, 2009 10:32 am

Re: Projection of Wire on Mesh

Postby wmayer » Sun May 19, 2019 5:11 pm

User avatar
HakanSeven12
Posts: 216
Joined: Wed Feb 06, 2019 10:30 pm

Re: Projection of Wire on Mesh

Postby HakanSeven12 » Sun May 19, 2019 5:30 pm

I will try it in the next windows build
Last edited by HakanSeven12 on Tue May 28, 2019 11:34 am, edited 1 time in total.
User avatar
HakanSeven12
Posts: 216
Joined: Wed Feb 06, 2019 10:30 pm

Re: Projection of Wire on Mesh

Postby HakanSeven12 » Tue May 28, 2019 11:33 am

wmayer wrote:
Sun May 19, 2019 5:11 pm
git commit b17a784e3
I tried. We talked about it but for topic:

Funchtion is creating projection if wire edge down on mesh, but if wire edge lie outside of mesh projection wire dont extend to mesh border.

Like this(Black one is original wire under mesh and red one is projected wire)


Projection.png
Projection.png (151.48 KiB) Viewed 147 times