intersezione fra rette

Forum per le domande e le discussioni in Italiano
Forum rules
regole del forum e le informazioni utili

Importante: PRIMA di chiedere aiuto leggete qui!
Post Reply
calculon
Posts: 26
Joined: Fri Nov 03, 2017 3:07 pm

intersezione fra rette

Post by calculon »

Ciao a tutti, qualcuno ha elaborato uno script per rilevare le coordinate esatte in cui due rette si intersecano?
un'altra richiesta: esiste un comando python per valutare se un punto appartiene ad una retta?
grazie mille!
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: intersezione fra rette

Post by renatorivo »

Ciao.
La soluzione per lo script sembra essere in questi due post:
https://forum.freecadweb.org/viewtopic.php?t=26650
https://forum.freecadweb.org/viewtopic.php?t=19698
io però n Windows ottengo sempre un errore 'DraftGeomUtils' is not defined anche con FreeCAD 0.19
non ho ancora provato in Ubuntu.
Puoi vedere altri post in inglese cercando con Script intersection
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: intersezione fra rette

Post by mario52 »

saluti

prova cosi:

seleziona le due linee

Code: Select all

import DraftGeomUtils
sel=Gui.Selection.getSelection()
print(DraftGeomUtils.findIntersection(sel[0].Shape.Edges[0],sel[1].Shape.Edges[0]))
intersection between two lines
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: intersezione fra rette

Post by renatorivo »

Grazie Mario, funziona:

Code: Select all

pl = FreeCAD.Placement()
>>> pl.Rotation.Q = (0.0,0.0,0.0,1.0)
>>> pl.Base = FreeCAD.Vector(0.0,0.0,0.0)
>>> points = [FreeCAD.Vector(0.0,0.0,0.0),FreeCAD.Vector(0.0,-40.0,0.0)]
>>> line = Draft.makeWire(points,placement=pl,closed=False,face=True,support=None)
>>> Draft.autogroup(line)
>>> pl = FreeCAD.Placement()
>>> pl.Rotation.Q = (0.0,0.0,0.0,1.0)
>>> pl.Base = FreeCAD.Vector(-20.0,-20.0,0.0)
>>> points = [FreeCAD.Vector(-20.0,-20.0,0.0),FreeCAD.Vector(20.0,-20.0,0.0)]
>>> line = Draft.makeWire(points,placement=pl,closed=False,face=True,support=None)
>>> Draft.autogroup(line)
>>> import DraftGeomUtils
>>> sel=Gui.Selection.getSelection()
>>> print(DraftGeomUtils.findIntersection(sel[0].Shape.Edges[0],sel[1].Shape.Edges[0]))
[Vector (0.0, -20.0, 0.0)]
>>> 
OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
Post Reply