0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FreeCADのpythonマクロでTree viewをReport viewに表示 してみた

Last updated at Posted at 2018-02-09
# -*- coding: utf-8 -*-
def MYSelect_all():
# https://forum.freecadweb.org/viewtopic.php?f=3&t=19248
# Code: Select all
    Gui.Selection.clearSelection()
    for obj in FreeCAD.ActiveDocument.Objects:
        if obj.ViewObject.isVisible():
           Gui.Selection.addSelection(obj)
    return
# ------------------------------------------------------
def MYclear_report():
# https://forum.freecadweb.org/viewtopic.php?t=9825
# clear console and clear report by python
    from PySide import QtGui
    mw=Gui.getMainWindow()
    r=mw.findChild(QtGui.QTextEdit, "Report view")
    r.clear()
    return
# ------------------------------------------------------
import time
print "開始:",time.ctime()
MYclear_report()
MYSelect_all()
# https://www.freecadweb.org/wiki/Manual/jp
# 選択機能を使う
for o in Gui.Selection.getSelectionEx():
	print "オブジェクト = ",o.ObjectName ,"(",o.Object.Label,")"
	for s in o.SubElementNames:
		print "name: ",s
	for s in o.SubObjects:
		print "object: ",s

Gui.Selection.clearSelection() 
print "終了"

# o.Labelとすると、以下のエラーがでます。
# <type 'exceptions.AttributeError'>: 'Gui.SelectionObject' object has no attribute 'Label'

(参考)マクロでラベルを出力する方法を教えて下さい
https://forum.freecadweb.org/viewtopic.php?f=16&t=26805

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?