FreeCAD-Doc/localwiki/Macro_Automatic_drawing-cs.html
2018-07-19 18:47:02 -05:00

150 lines
7.2 KiB
HTML

<html><head><title>Macro Automatic drawing/cs</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Automatic drawing/cs</h1></div>
<div id="mw-content-text" lang="cs" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
<tr>
<td class="ctTitle">
<h3><span class="mw-headline" id="Automatic_drawing"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Automatic drawing</span></h3>
</td></tr>
<tr>
<th class="ctOdd">Description
</th></tr>
<tr>
<td class="ctEven left macro-description">Tento kód umožňuje uživateli vytvořit pohled na výkres se 4 různými pozicemi vybraného objektu (zepředu, shora, iso, zprava). Aby byl dokonale efektivní, potřeboval by ještě pár úprav.
</td></tr>
<tr>
<th class="ctOdd">Author
</th></tr>
<tr>
<td class="ctEven macro-author"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Unknown&amp;action=edit&amp;redlink=1" class="new" title="User:Unknown (page does not exist)">unknown</a>
</td></tr>
<tr>
<th class="ctOdd">Links
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/cs" title="Macros recipes/cs">Makro návody</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/cs" title="How to install macros/cs">How to install macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/cs" title="Customize Toolbars/cs">How to customize toolbars</a>
</td></tr>
<tr>
<th class="ctOdd">Version
</th></tr>
<tr>
<td class="ctEven macro-version">1.0
</td></tr>
<tr>
<th class="ctOdd">Date last modification
</th></tr>
<tr>
<td class="ctEven macro-date">2016-09-26
</td></tr>
<tr>
<th class="ctOdd">
</th></tr>
<tr>
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#Automatic_drawing"><span class="tocnumber">1</span> <span class="toctext">Automatic drawing</span></a>
<ul>
<li class="toclevel-2 tocsection-1"><a href="#Pou.C5.BEit.C3.AD"><span class="tocnumber">1.1</span> <span class="toctext">Použití</span></a></li>
<li class="toclevel-2 tocsection-2"><a href="#Omezen.C3.AD"><span class="tocnumber">1.2</span> <span class="toctext">Omezení</span></a></li>
<li class="toclevel-2 tocsection-3"><a href="#Skript"><span class="tocnumber">1.3</span> <span class="toctext">Skript</span></a></li>
</ul>
</li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p><p>Tento kód generuje stránku <a href="https://www.freecadweb.org/wiki/index.php?title=Drawing_Module/cs" title="Drawing Module/cs">Výkresu</a> se třemi ortografickými vzájemně zarovnanými pohledy (zepředu, shora a zprava) a izometrický pohled umístěný vpravo nahoře stránky. Vypočítá měřítko založené na velikosti modelu a rozměru a dostupnému místu na stránce. Izo pohled je v poměru 2/3 k orto pohledům.<br />
Používá <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Multiview_orthographic_projection#First-angle_projection">pravoúhlé promítání</a>.
</p>
<h4><span class="mw-headline" id="Pou.C5.BEit.C3.AD">Použití</span></h4>
<p>Před spuštěním makra musí být vybrán objekt.
</p>
<h4><span class="mw-headline" id="Omezen.C3.AD">Omezení</span></h4>
<ul><li> Měřítko není standardní. Možná budete muset měnit pohledy ručně abyste se dostali na standardní měřítko.</li>
<li> Funguje pouze s jedním objektem (to je omezení z pracovní plochy Výkres)</li>
<li> Pro použití v <a rel="nofollow" class="external text" href="http://en.wikipedia.org/wiki/Multiview_orthographic_projection#Third-angle_projection">third-angle projection</a> používaným v USA a Kanadě musí být provedeny určité úpravy.</li></ul>
<h4><span class="mw-headline" id="Skript">Skript</span></h4>
<pre>import FreeCAD, Part, Drawing
if len(Gui.Selection.getSelectionEx())&gt;1:
App.Console.PrintError("Warning: Only the first item is generate")
if len(Gui.Selection.getSelectionEx())==0:
App.Console.PrintError("Warning: Need to select one item")
Piece=Gui.Selection.getSelectionEx()[0]
App.activeDocument().addObject('Drawing::FeaturePage','AutoDrawing')
App.activeDocument().AutoDrawing.Template = App.getResourceDir()+'Mod/Drawing/Templates/A3_Landscape.svg'
DH=20
DL=30
L=Piece.Object.Shape.BoundBox.XMax
H=Piece.Object.Shape.BoundBox.ZMax
P=Piece.Object.Shape.BoundBox.YMax
Sc=(400-3*DL)/(L+H)
Sc2=(250-3*DH)/(P+H)
if Sc&gt;Sc2&#160;:
Sc=Sc2
TopX=DL+Sc*L
FrontX=DL+Sc*L
RightX=2*DL+Sc*L
IsoX=2*DL+Sc*(L)
TopY=DH+Sc*P
RightY=DH+P*Sc
FrontY=2*DH+Sc*(P+H)
IsoY=2*DH+Sc*P
print TopX,RightX,TopY,FrontY
#Create topView
App.activeDocument().addObject('Drawing::FeatureViewPart','topView')
App.activeDocument().topView.Source =Piece.Object
App.activeDocument().topView.Direction = (0,0,1)
App.activeDocument().topView.Rotation=180
App.activeDocument().topView.X = TopX
App.activeDocument().topView.Y = TopY
App.activeDocument().topView.ShowHiddenLines=True
App.activeDocument().AutoDrawing.addObject(App.activeDocument().topView)
App.activeDocument().topView.Scale = Sc
#Create FrontView
App.activeDocument().addObject('Drawing::FeatureViewPart','FrontView')
App.activeDocument().FrontView.Source =Piece.Object
App.activeDocument().FrontView.Direction = (0,-1,0)
App.activeDocument().FrontView.Rotation=90
App.activeDocument().FrontView.Scale = Sc
App.activeDocument().FrontView.X = FrontX
App.activeDocument().FrontView.Y = FrontY
App.activeDocument().FrontView.ShowHiddenLines=True
App.activeDocument().AutoDrawing.addObject(App.activeDocument().FrontView)
#Create RightView
App.activeDocument().addObject('Drawing::FeatureViewPart','RightView')
App.activeDocument().RightView.Source =Piece.Object
App.activeDocument().RightView.Direction = (1,0,0)
App.activeDocument().RightView.Scale = Sc
App.activeDocument().RightView.X = RightX
App.activeDocument().RightView.Y = RightY
App.activeDocument().RightView.ShowHiddenLines=True
App.activeDocument().AutoDrawing.addObject(App.activeDocument().RightView)
#Create IsotView
App.activeDocument().addObject('Drawing::FeatureViewPart','IsoView')
App.activeDocument().IsoView.Source =Piece.Object
App.activeDocument().IsoView.Direction = (1,1,1)
App.activeDocument().IsoView.Rotation=60
App.activeDocument().IsoView.Scale = Sc*.6
App.activeDocument().IsoView.X = IsoX
App.activeDocument().IsoView.Y = IsoY
App.activeDocument().IsoView.ShowHiddenLines=True
App.activeDocument().AutoDrawing.addObject(App.activeDocument().IsoView) </pre>
<div style="clear:both"></div>
</div>
</div>
</div><div class="printfooter">
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Automatic_drawing/cs&amp;oldid=240122">http://www.freecadweb.org/wiki/index.php?title=Macro_Automatic_drawing/cs&amp;oldid=240122</a>"</div>
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
</body></html>