FreeCAD Logo FreeCAD 1.0
  • English Afrikaans Arabo Bielorusso Catalano Czech German Greek Spanish Spanish Basco Finnish Filippino Français Galiziano Croatian Hungarian Indonesiano Italiano Japanese Kabyle Coreano Lituano Dutch Norvegese Bokmal Polish Portuguese Portuguese Romanian Russian Slovak Slovenian Serbo Swedish Turkish Ukrainian Valenziano Vietnamita Cinese Cinese
  • Funzioni
  • Download
  • Blog
  • Documentazione
    Indice di documentazione Per iniziare Documentazione utenti Il manuale FreeCAD Documentazione degli ambienti di lavoro Documentazione di scripting Python Documentazione codice C++ Tutorial Domande frequenti Politica sulla Privacy Informazioni Su FreeCAD
  • Contribuire
    Come aiutare Sponsor Segnala un bug Fai una richiesta Opportunità di lavoro e ricompense Linee guida per contribuire Manuale degli sviluppatori Traduzioni
  • Comunità
    Codice di condotta Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendario
  • ♥ Donate

Donate

$
Informazioni SEPA
Si prega di intestare il bonifico SEPA a:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Agenzia bancaria: BNP Paribas Fortis
Indirizzo: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Icona macro generica. Crea la tua icona personale con lo stesso nome della macro Macro di Draft Tangente al Cerchio

Descrizione
Crea tangenti ai cerchi di Draft.

Versione macro: 0.2
Ultima modifica: 2022-11-27
Versione FreeCAD: -
Autore: heda
Autore
heda
Download
None
Link
Raccolta di macro
Come installare le macro
Personalizzare la toolbar
Versione macro
0.2
Data ultima modifica
2022-11-27
Versioni di FreeCAD
-
Scorciatoia
Nessuna
Vedere anche
Nessuno

Descrizione

Macro di Draft Tangente al Cerchio

Utilizzo

Selezionare e lanciare.

Installazione

Attraverso Addon manager.

Versione

v0.2 2022-11-27 : Corretta la selezione del punto in Draft nella vista ad albero.

v0.1 2022-11-21 : Primo rilascio.

Codice

Macro_Draft_Circle_Tangent.FCMacro

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# ***************************************************************************
# *   Copyright (c) 2022 heda <heda @ freecad forum>                        *
# *                                                                         *
# *   This file is part of the FreeCAD CAx development system.              *
# *                                                                         *
# *   This program is free software; you can redistribute it and/or modify  *
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
# *   as published by the Free Software Foundation; either version 2 of     *
# *   the License, or (at your option) any later version.                   *
# *   for detail see the LICENCE text file.                                 *
# *                                                                         *
# *   This program is distributed in the hope that it will be useful,       *
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
# *   GNU Library General Public License for more details.                  *
# *                                                                         *
# *   You should have received a copy of the GNU Library General Public     *
# *   License along with this program; if not, write to the Free Software   *
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
# *   USA                                                                   *
# *                                                                         *
# ***************************************************************************


__Name__ = 'Draft_Circle_Tangent'
__Comment__ = 'Makes tangents to draft circles.'
__Author__ = 'heda @ fc-forum'
__Version__ = '0.2'
__Date__ = '2022-11-27'
__License__ = 'LGPL-2.0-or-later'
__Web__ = ''
__Wiki__ = 'https://wiki.freecad.org/Macro_Draft_Circle_Tangent'
__Icon__ = ''
__Help__ = 'Select and launch.'
__Status__ = 'functional'
__Requires__ = 'tested on FreeCAD v0.20'
__Communication__ = ''
__Files__ = ''


__doc__ = """
makes tangents for draft circles and arcs
a) circle and vertex/point
b) two circles

select before launching macro

for circle and point the tangents are constructed,
as one would do with pen and paper
for circle and circle the angles are calculated,
one can also construct the tangents in a similar way to
circle/point way, i.e. intersections by additional construction circles

note: tesselation often makes the true tangent not look like a true tangent
this is to not overload rendering for larger projects
one can change the viewsetting deviation for the circle to minimum (0.01)
if one wants to better view the true tangent, if so, better turn that back
to default once viewed - it is easy to forget that this has been done,
and can in larger projects put fc to more or less a complete halt.
"""

from math import sin, cos, pi, atan2, acos, asin

import Draft

doc = App.ActiveDocument
cgroup = doc.addObject('App::DocumentObjectGroup','Construction')
Vector, Placement = App.Vector, App.Placement
RotZero = Placement().Rotation

def get_curve(obj):
    return obj.Shape.Edge1.Curve

def point2vector(pt):
    return pt.toShape().Point

def get_intersection_points(obj1, obj2):
    doc.recompute()
    i1, i2 = get_curve(obj1).intersect(get_curve(obj2))
    return (point2vector(p) for p in (i1, i2))

def add_construction(obj):
    _ = cgroup.addObject(obj)

def mk_line(v1, v2, construction=True):
    line = Draft.make_line(v1, v2)
    if construction:
        line.ViewObject.DrawStyle = 'Dashdot'
        add_construction(line)
    return line

def mk_circle(centre, radius):
    circle = Draft.make_circle(radius, Placement(centre, RotZero), False)
    circle.ViewObject.DrawStyle = 'Dashed'
    add_construction(circle)
    return circle


## selection logic
SINGLE = False
msg = ('select exactly 2 items, 2 (draft) circles '
        'or 1 (draft) circle and one vertex or (draft) point')
selection = Gui.Selection.getSelection()
if len(selection) == 2:
    s1, s2 = selection
    r1, r2 = (hasattr(r, 'Radius') for r in selection)
    if r1 and r2:
        c1s, c2s = s1, s2
    elif not r1 and not r2:
        raise RunTimeWarning(msg)
    else:
        SINGLE = True
        circle = s1 if r1 else s2
        sx1, sx2 = Gui.Selection.getSelectionEx()
        sx = sx2 if r1 else sx1
        if sx.PickedPoints:
            point, = sx.PickedPoints
        else: # it is a draft point selected in tree view
            point = sx.Object.Shape.Point
    
else:
    raise RunTimeWarning(msg)

if SINGLE:

    o = circle.Placement.Base
    op = point - o

    ccircle = mk_circle(o + op/2, op.Length/2)

    v1, v2 = get_intersection_points(circle, ccircle)

    tangent1 = mk_line(point, v1, False)
    tangent2 = mk_line(point, v2, False)


else:

    # c1 is the larger one
    if c1s.Radius >= c2s.Radius:
        c1, c2 = c1s, c2s
    else:
        c1, c2 = c2s, c1s

    c1c, c2c = c1.Placement.Base, c2.Placement.Base

    centerline = mk_line(c1c, c2c)
    cc = c2c - c1c

    # construction circle outer tangent
    c3 = mk_circle(c1c, c1.Radius - c2.Radius)

    phi1 = atan2(cc.y, cc.x) + acos(c3.Radius / cc.Length)
    v1 = Vector(cos(phi1), sin(phi1), 0).normalize()
    line = mk_line(c1c, v1 * c1.Radius + c1c)
    ot1 = mk_line(c1c + v1 * c1.Radius, c2c + v1 * c2.Radius, False)

    phi2 = atan2(cc.y, cc.x) - acos(c3.Radius / cc.Length)
    v2 = Vector(cos(phi2), sin(phi2), 0).normalize()
    line2 = mk_line(c1c, v2 * c1.Radius + c1c)
    ot2 = mk_line(c1c + v2 * c1.Radius, c2c + v2 * c2.Radius, False)

    # construction circle inner tangent
    c4 = mk_circle(c2c, c1.Radius + c2.Radius)

    phi1 = atan2(cc.y, cc.x) + asin(c4.Radius / cc.Length) - pi/2
    v1 = Vector(cos(phi1), sin(phi1), 0).normalize()
    line = mk_line(c2c, -v1 * c2.Radius + c2c)
    ot1 = mk_line(c1c + v1 * c1.Radius, c2c - v1 * c2.Radius, False)

    phi2 = atan2(cc.y, cc.x) - asin(c4.Radius / cc.Length) + pi/2
    v2 = Vector(cos(phi2), sin(phi2), 0).normalize()
    line2 = mk_line(c2c, - v2 * c2.Radius + c2c)
    ot2 = mk_line(c1c + v2 * c1.Radius, c2c - v2 * c2.Radius, False)

cgroup.ViewObject.Visibility = False
doc.recompute()

Questa pagina è recuperata da https://wiki.freecad.org/Macro_Draft_Circle_Tangent

Tieniti aggiornato!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© The FreeCAD Team. Homepage image credits (top to bottom): ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

Questo progetto è supportato da: , KiCad Services Corp. e altri sponsor

GitHubMigliora questa pagina su GitHub