FreeCAD Logo FreeCAD 1.0
  • angielski afrykanerski arabski białoruski kataloński czeski niemiecki grecki hiszpański hiszpański baskijski fiński filipiński francuski galicyjski chorwacki węgierski Indonezyjski włoski japoński kabylski koreański litewski duński Norweski Bokmal polski portugalski portugalski rumuński rosyjski słowacki słoweński serbski szwedzki turecki ukraiński walenciański wietnamski chiński chiński
  • Funkcjonalność programu
  • Pobierz
  • Blog
  • Dokumentacja
    Spis dokumentacji Jak zacząć Dokumentacja użytkowników Podręcznik do programu FreeCAD Dokumentacja środowisk pracy Dokumentacja skryptów środowiska Python Dokumentacja kodowania C++ Poradniki Najczęściej zadawane pytania Polityka prywatności O FreeCAD
  • Przyłącz się do projektu
    Jak pomóc Sponsor Zgłoś błąd Utwórz pull request Praca i finansowanie Zasady współpracy Podręcznik dla programistów Tłumaczenia
  • Społeczność
    Kodeks postępowania Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Kalendarz
  • ♥ Donate

Donate

$
Informacje o SEPA
Skonfiguruj przelew bankowy SEPA do:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Bank: BNP Paribas Fortis
Adres: 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!

GenerateDrawing

Opis
Makro do automatycznego generowania rysunku z 3 rzutami prostokątnymi oraz jednym izometrycznym.

Macro version: 1.0.0
Last modified: 2022-01-08
FreeCAD version: 0.18.4 i nowszy
Download: Ikona paska narzędzi
Autor: PR-DC
Autor
PR-DC
Do pobrania
Ikona paska narzędzi
Odnośniki
Przepisy na makropolecenia
Jak zainstalować makrodefinicje
Dostosowanie pasków narzędzi
Wersja Makrodefinicji
1.0.0
Data zmian
2022-01-08
Wersja FreeCAD
0.18.4 i nowszy
Domyślny skrót
Brak
Zobacz również
repozytorium GitHub

Opis

Makro do automatycznego generowania rysunku z 3 rzutami ortogonalnymi oraz jednym izometrycznym.

Użycie

Otwórz model i uruchom makro (sprawdź parametry wejściowe w kodzie makra, aby je dostosować).

Skrypt

Ikona paska narzędzi

GenerateDrawing.FCMacro

# Macro for automatic drawing generation 
# with 3 normal projections and one isometric.
# Author: Milos Petrasinovic <mpetrasinovic@pr-dc.com>
# PR-DC, Republic of Serbia
# info@pr-dc.com
# 
# --------------------
#
# Copyright (C) 2022 PRDC <info@pr-dc.com>
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as 
# published by the Free Software Foundation, either version 3 of the 
# License, or (at your option) any later version.
#  
# 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 Lesser General Public License for more details.
#  
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
# ----- PARAMS -----
paper = [420, 297] # A3 paper size
border = [10, 10, 400, 277] # border position ans size
table = [190, 74] # table size
dx = 10 # space between views along x axis
dy = 10 # space between views along y axis
author = "Miloš Petrašinović" # author name
drawn_date = "07.01.2022." # drawing drawn date
template_file = "test\\PRDC_template_A3.svg" # drawing template
# --------------------

__Name__ = 'GenerateDrawing'
__Comment__ = 'Macro for automatic drawing generation.'
__Author__ = 'Milos Petrasinovic <mpetrasinovic@pr-dc.com>'
__Version__ = '1.0.0'
__Date__ = '2022-01-07'
__License__ = 'GPL-3.0-or-later'
__Web__ = 'https://github.com/PR-DC/PRDC_GenerateDrawing_FC'
__Wiki__ = 'https://wiki.freecad.org/Macro_GenerateDrawing'
__Icon__ = 'https://wiki.freecad.org/images/7/74/GenerateDrawing.svg'
__Help__ = 'Open model and run the macro program!'
__Status__ = 'stable'
__Requires__ = 'Freecad >= 0.18'
__Communication__ = 'https://github.com/PR-DC/PRDC_GenerateDrawing_FC/issues/'
__Files__ = 'GenerateDrawing.svg'

import FreeCAD as App
import FreeCADGui as Gui
from PySide import QtGui
import Draft
import math
import os

if not os.path.isabs(template_file):
    template_file = os.path.dirname(__file__) + '\\' + template_file
print(template_file)

doc = App.activeDocument()
doc_gui = Gui.activeDocument()
Gui.activateWorkbench("TechDrawWorkbench")
shapes = []

def GetShapes(objs, shapes):
    for obj in objs:
        if obj.TypeId == 'App::DocumentObjectGroup':
            GetShapes(obj.OutList, shapes)
        elif hasattr(obj, "Shape") and doc_gui.getObject(obj.Name).Visibility:
            shapes.append(obj)
    return shapes
    
if doc is not None:
    shapes = GetShapes(doc.RootObjects, shapes)
    if len(shapes):
        if len(shapes) == 1:
            model = shapes[0]
        else:
            model = doc.addObject("Part::Compound", "DrawingModel")
            model.Links = shapes
            doc.recompute()
        
        # Obtain model bounding box
        BB = model.Shape.BoundBox
        X = BB.XMax-BB.XMin
        Y = BB.YMax-BB.YMin
        Z = BB.ZMax-BB.ZMin
        
        Isometric = Draft.makeShape2DView(model, App.Vector(0.57735, 0.57735, 0.57735))
        doc.recompute()
        IBB = Isometric.Shape.BoundBox
        if App.Version()[1] < "19":
            Xrot = IBB.XMin+(IBB.XMax-IBB.XMin)/2
            Yrot = IBB.YMin+(IBB.YMax-IBB.YMin)/2
            Draft.rotate(Isometric, -120, center=App.Vector(Xrot, Yrot, 0), axis=App.Vector(0, 0, 1), copy=False)
            doc.recompute()
            IBB = Isometric.Shape.BoundBox
        IsometricBB = [IBB.XMax-IBB.XMin, IBB.YMax-IBB.YMin]
        
        doc.removeObject(Isometric.Name)
        if len(shapes) > 1:
            doc.removeObject(model.Name)
            for obj in shapes:
                doc_gui.getObject(obj.Name).Visibility = True
                
        # Page scale
        p1 = border[2]/(X+dx+Z)
        p2 = border[3]/(Y+dy+Z)
        
        if p1 < 1 or p2 < 1:
            # Decrease
            if p1 > p2:
                s = math.ceil(1/p2)
            else:
                s = math.ceil(1/p1)
            s = 1/s
            scale_str = "1:"+str(s)
        else:
            # Increase
            if p1 > p2:
                s = math.floor(p2)
            else:
                s = math.floor(p1)
            scale_str = str(s)+":1"
        
        # Add page with template
        page = doc.addObject('TechDraw::DrawPage', 'Page')
        template = doc.addObject('TechDraw::DrawSVGTemplate', 'Template')
        template.Template = template_file
        page.Template = template
        page.Scale = s
        
        # Add project group views
        views = doc.addObject('TechDraw::DrawProjGroup', 'ProjGroup')
        views.AutoDistribute = False
        page.addView(views)
        views.Source = shapes
        doc.recompute()
        Top = views.addProjection('Front')
        Top.Label = "Top"
        views.Anchor.Direction = App.Vector(0, 0, 1)
        if App.Version()[1] >= "19":
            views.Anchor.XDirection = App.Vector(1, 0, 0)
        views.Anchor.RotationVector = App.Vector(1, 0, 0)
        views.Anchor.recompute()
        views.ProjectionType = 'First Angle'
        Front = views.addProjection('Top')
        Front.Label = "Front"
        Left = views.addProjection('Left')
        Left.Label = "Left"
        
        # Isometric view
        Isometric = doc.addObject('TechDraw::DrawViewPart', 'Isometric')
        page.addView(Isometric)
        Isometric.Source = shapes
        Isometric.ScaleType = "Custom"
        Isometric.Scale = s/2
        Isometric.Label = "Isometric"
        Isometric.Direction = App.Vector(0.57735, 0.57735, 0.57735)
        if App.Version()[1] >= "19":
            Isometric.XDirection = App.Vector(0.57735, 0.57735, 0.57735)
        else: 
            Isometric.Rotation = -120.00
        Isometric.recompute()
           
        # Views position
        px0 = border[0]+dx
        py0 = paper[1]-dy-border[1]
        
        views.X = px0+s*X/2
        views.Y = py0-s*Y/2
        Front.Y = -(s*Y/2+dy+s*Z/2)
        Left.X = s*X/2+dx+s*Z/2
        Isometric.X = paper[0]-border[0]-dx-s/2*IsometricBB[0]/2
        Isometric.Y = border[1]+table[1]+dy+s/2*IsometricBB[1]/2
        
        # Change drawing text fields
        template.setEditFieldContent("AUTHOR_NAME", author)
        template.setEditFieldContent("AUTHOR_DATE", drawn_date)
        template.setEditFieldContent("DRAWING_SCALE", scale_str)
        template.setEditFieldContent("PROJECT_NAME", "PROJECT NAME")
        template.setEditFieldContent("DRAWING_TITLE", "DRAWING TITLE")
        template.setEditFieldContent("PCS_NUMBER", "X pcs")
        template.setEditFieldContent("MATERIAL_NAME", "x")
        template.setEditFieldContent("FINISH_TYPE", "As Produced")
        template.setEditFieldContent("TOLERANCE_VALUE", "xxx")
        template.setEditFieldContent("SUPERVISOR_NAME", "Supervisor")
        template.setEditFieldContent("SUPERVISOR_DATE", "xxx")
        template.setEditFieldContent("DESIGNER_NAME", "Designer")
        template.setEditFieldContent("DESIGNER_DATE", "xxx")
        template.setEditFieldContent("PAGE_SIZE", "A3")
        template.setEditFieldContent("REV_NUMBER", "X")
        template.setEditFieldContent("PART_WEIGHT", "XXX")
        template.setEditFieldContent("SHEET_NUMBER", "1/1")
        
        doc.recompute()        
        doc_gui.getObject(page.Name).show()
        Gui.updateGui()
    else:
        msgBox = QtGui.QMessageBox()
        msgBox.setWindowTitle("Error")
        msgBox.setText("No shapes for drawing!")
        msgBox.exec_()
        App.Console.PrintError("\nError: No shapes for drawing!\n")
else:
    msgBox = QtGui.QMessageBox()
    msgBox.setWindowTitle("Error")
    msgBox.setText("No active document!")
    msgBox.exec_()
    App.Console.PrintError("\nError: No active document!\n")

Łącza

Dyskusja na forum New Macros: GenerateViews and GenerateDrawing

Ta strona pochodzi z https://wiki.freecad.org/Macro_GenerateDrawing

Bądźmy w kontakcie!
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© Załoga FreeCAD. Autorami grafiki na stronie głównej (od góry do dołu) są: ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

Ten projekt jest wspierany przez: , KiCad Services Corp. oraz pozostałych sponsorów

GitHubUlepsz tę stronę na GitHub