[Solved]Projection of Wire on Mesh

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
HakanSeven12
Veteran
Posts: 1481
Joined: Wed Feb 06, 2019 10:30 pm

[Solved]Projection of Wire on Mesh

Post by HakanSeven12 »

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 2171 times
Last edited by HakanSeven12 on Sun Sep 08, 2019 7:00 pm, edited 4 times in total.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Projection of Wire on Mesh

Post by Joel_graff »

@microelly2 can probably answer that one.
microelly2 wrote: ping
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
jbi
Posts: 117
Joined: Sun Apr 24, 2016 3:28 pm

Re: Projection of Wire on Mesh

Post by jbi »

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

Re: Projection of Wire on Mesh

Post by microelly2 »

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
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Projection of Wire on Mesh

Post by wmayer »

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
Veteran
Posts: 1481
Joined: Wed Feb 06, 2019 10:30 pm

Re: Projection of Wire on Mesh

Post by HakanSeven12 »

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
Veteran
Posts: 1481
Joined: Wed Feb 06, 2019 10:30 pm

Re: Projection of Wire on Mesh

Post by HakanSeven12 »

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 2336 times

second.png
second.png (118.95 KiB) Viewed 2336 times
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Projection of Wire on Mesh

Post by wmayer »

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

Re: Projection of Wire on Mesh

Post by HakanSeven12 »

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
Veteran
Posts: 1481
Joined: Wed Feb 06, 2019 10:30 pm

Re: Projection of Wire on Mesh

Post by HakanSeven12 »

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 2218 times
Post Reply