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!
calculon
Posts: 26
Joined: Fri Nov 03, 2017 3:07 pm

intersezione fra rette

Postby calculon » Wed May 29, 2019 1:23 pm

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
Posts: 2255
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: intersezione fra rette

Postby renatorivo » Wed May 29, 2019 9:00 pm

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
Posts: 2682
Joined: Wed May 16, 2012 2:13 pm

Re: intersezione fra rette

Postby mario52 » Sat Jun 01, 2019 11:35 am

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, Dialog creation. My macros on Gist.github.
renatorivo
Posts: 2255
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: intersezione fra rette

Postby renatorivo » Sat Jun 01, 2019 12:19 pm

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)