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

159 lines
7.3 KiB
HTML

<html><head><title>Macro Print SceneGraph/it</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 Print SceneGraph/it</h1></div>
<div id="mw-content-text" lang="it" 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="Stampa_SceneGraph"><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> Stampa SceneGraph</span></h3>
</td></tr>
<tr>
<th class="ctOdd">Descrizione
</th></tr>
<tr>
<td class="ctEven left">Stampa SceneGraph
</td></tr>
<tr>
<th class="ctOdd">Autore
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Aleph0&amp;action=edit&amp;redlink=1" class="new" title="User:Aleph0 (page does not exist)">Aleph0</a>
</td></tr>
<tr>
<th class="ctOdd">Link
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/it" title="Macros recipes/it">Esempi di macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/it" title="How to install macros/it">Come installare le Macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/it" title="Customize Toolbars/it">Personalizzare la barra degli strumenti</a>
</td></tr>
<tr>
<th class="ctOdd">Versione
</th></tr>
<tr>
<td class="ctEven macro-version">00.03
</td></tr>
<tr>
<th class="ctOdd">Data ultima modifica
</th></tr>
<tr>
<td class="ctEven macro-date">2017-10-24
</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="#Stampa_SceneGraph"><span class="tocnumber">1</span> <span class="toctext">Stampa SceneGraph</span></a></li>
<li class="toclevel-1 tocsection-1"><a href="#Descrizione"><span class="tocnumber">2</span> <span class="toctext">Descrizione</span></a></li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p>
<h2><span class="mw-headline" id="Descrizione">Descrizione</span></h2>
<p>Questa macro attraversa SceneGraph e stampa tutti i nodi e i relativi campi nella finestra Vista Report. Può essere utilizzata solo per informazioni, ma è possibile aggiungere del codice per modificare in qualche modo delle parti di SceneGraph o stampare più dettagli per particolari tipi di nodi.
</p>
<pre># -*- coding: utf-8 -*-
"""
***************************************************************************
* *
* This macro traverses the SceneGraph and prints all the nodes and *
* their fields in the Report View window. It can be used just for *
* information or you can add code to modify parts of the SceneGraph in *
* some way or print more details for particular types of node. *
* *
***************************************************************************
* Copyright © 2017 Richard P. Parkins, M. A. *
* *
* This file is a supplement to 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 software 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 macro; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************
"""
__title__ = "Print_SceneGraph"
__author__ = "Aleph0"
__version__ = "00.03"
__date__ = "24/10/2017"
__Comment__ = "SceneGraph explorer"
__Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_Print_SceneGraph"
__Help__ = "see first few lines of macro text"
__Status__ = "stable"
__Requires__ = "freecad 0.16"
#OS: Ubuntu 14.04.5 LTS
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.16.6703 (Git)
#Build type: None
#Branch: releases/FreeCAD-0-16
#Hash: 2ce5c8d2e3020d05005ed71f710e09e9aa561f40
#Python version: 2.7.6
#Qt version: 4.8.6
#Coin version: 4.0.0a
#OCC version: 6.8.0.oce-0.17
import FreeCAD
from pivy import coin
def printFields(node,indent):
nm = node.getName().__str__()
if nm&#160;!= "":
FreeCAD.Console.PrintLog(indent+"name: "+nm+"\n")
fl = node.getFieldData()
for i in range(fl.getNumFields()):
name = fl.getFieldName(i)
if name.__str__()&#160;!= "point":
val = node.getField(fl.getFieldName(i)).get()
FreeCAD.Console.PrintLog(indent+str(name)+" -&gt; "+str(val)+"\n")
def printTree(node,indent):
FreeCAD.Console.PrintLog(indent+node.__str__()+"\n")
if node.getTypeId().getName().__str__() == "Coordinate3":
points=node.point
for i in range(points.getNum()):
FreeCAD.Console.PrintLog(indent+" "+str(i)+": "+str(points[i].getValue())+"\n")
if node.getTypeId().getName().__str__() == "Coordinate4":
points=node.point
for i in range(points.getNum()):
FreeCAD.Console.PrintLog(indent+" "+str(i)+": "+str(points[i].getValue())+"\n")
printFields(node,indent+" ")
if node.getChildren().__str__()&#160;!= "None":
for i in range(node.getNumChildren()):
printTree(node.getChild(i),indent+" ")
ad = FreeCADGui.ActiveDocument
if ad == None:
FreeCAD.Console.PrintLog("No active document\n")
else:
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
printTree(ad.ActiveView.getViewer().getSoEventManager().getSceneGraph(), "")
QtGui.QApplication.restoreOverrideCursor() </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_Print_SceneGraph/it&amp;oldid=254302">http://www.freecadweb.org/wiki/index.php?title=Macro_Print_SceneGraph/it&amp;oldid=254302</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>