FreeCAD Logo FreeCAD 1.0
  • Anglais Afrikaans Arabe Biélorusse Catalan Tchèque Allemand Grec Espagnol Espagnol Basque Finnois Philippin Français Galicien Croate Hongrois Indonésien Italien Japonais Kabyle Coréen Lituanien Néerlandais Norvégien classique Polonais Portugais Portugais Roumain Russe Slovaque Slovène Serbe Suédois Turc Ukrainien Valencien Vietnamien Chinois Chinois
  • Fonctions
  • Télécharger
  • Blog
  • Documentation
    Index de la documentation Premiers pas Documentation pour les utilisateurs Manuel de FreeCAD Documentation des ateliers Documentation sur le codage en Python Documentation pour les développeurs Tutoriels Foire aux questions Politique de confidentialité À propos de FreeCAD
  • Contribuer
    Comment aider Sponsor Signaler un bogue Faire une demande de modification (PR) Emplois et financements Guide pour les contributions Manuel pour les développeurs Traductions
  • Communauté
    Code de conduite Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendrier
  • ♥ Donate

Donate

$
Informations SEPA
Veuillez configurer votre virement bancaire SEPA pour:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Agence bancaire: BNP Paribas Fortis
Adresse: 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!

Macro Align Object BoundBox Center

Description
Aligne 2 objets (ou plus) par le centre de leurs boîtes englobantes.

Version macro : 0.2
Date dernière modification : 2024-11-10
Auteur: heda
Auteur
heda
Téléchargement
None
Liens
Page des macros
Comment installer une macro
Comment créer une barre d'outils
Version Macro
0.2
Dernière modification
2024-11-10
Version(s) FreeCAD
Raccourci clavier
None
Voir aussi
None

Description

Cette macro aligne 2 objets (ou plus) par le centre de leurs boîtes englobantes.

Macro Align Object BoundBox Center

Utilisation

Sélectionnez et lancez.

Installation

Par le biais du gestionnaire des extensions.

Version

  • v0.2 2024-11-10 : gère maintenant aussi les dessins/textes.
  • v0.1 2024-10-23 : première version.

Code

Macro_Align_Object_BoundBox_Center.FCMacro

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

# ***************************************************************************
# *   Copyright (c) 2024 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__ = 'Macro_Align_Object_BoundBox_Center'
__Comment__ = 'Aligns 2 (or more) objects by bounding box'
__Author__ = 'heda @ fc-forum'
__Version__ = '0.2'
__Date__ = '2024-11-10'
__License__ = 'LGPL-2.0-or-later'
__Web__ = ''
__Wiki__ = 'https://wiki.freecad.org/Macro_Align_Object_BoundBox_Center'
__Icon__ = ''
__Help__ = 'Select and launch.'
__Status__ = 'functional'
__Requires__ = 'tested on FreeCAD v0.21'
__Communication__ = ''
__Files__ = ''


__doc__ = """
select 2 or more objects and run macro.
first object is reference, and all subsequent
selections will get a placement that has the
centre at same location as the reference object.

undo transaction is commented out,
since it moves the object back twice...
"""


import FreeCAD as App
import FreeCADGui as Gui

doc = App.ActiveDocument
sel = Gui.Selection.getSelection()

def getBBox(obj):
    if hasattr(obj, 'Shape'):
        return obj.Shape.BoundBox
    elif hasattr(obj.'ViewObject'):
        return obj.ViewObject.getBoundingBox()
    else:
        return None

if len(sel) > 1:

    ref, *moves = sel
    refbb = getBBox(ref)
    msg_skip = 'could not find bbox for {}, skipping...)'
    if refbb:
        # doc.openTransaction('Bbox align objects')
        moved = list()
        for move in moves:
            movebb = getBBox(move)
            if movebb:
                vec = refbb.Center - movebb.Center
                move.Placement.Base = move.Placement.Base + vec
                moved.append(move)
            else:
                print(msg_skip.format(move.Label))
        doc.recompute()
        # doc.commitTransaction()
        if moved:
            txt = [obj.Label for obj in moved]
            print('moved {} to {}'.format(', '.join(txt), ref.Label))
        else:
            print('could not move any objects')
    else:
        print('could not find bbox for ref-obj, bailing...')

Cette page est extraite de https://wiki.freecad.org/Macro_Align_Object_BoundBox_Center

Contactez-nous !
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© L'équipe FreeCAD. Crédits des images de la page d'accueil (de haut en bas) : ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

Ce projet est soutenu par : , KiCad Services Corp. et autres parrains

GitHubAméliorer cette page sur GitHub