マクロでラベルを出力する方法を教えて下さい

Japanese forum
mrrclb48z
Posts: 27
Joined: Wed Feb 07, 2018 11:20 am

マクロでラベルを出力する方法を教えて下さい

Postby mrrclb48z » Thu Feb 08, 2018 12:18 pm

# -*- 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()
MYSelect_all()
# https://www.freecadweb.org/wiki/Manual/jp
# 選択機能を使う
for o in Gui.Selection.getSelectionEx():
print "オブジェクトネーム = ",o.ObjectName
# print "ラベル = ",o.Label
for s in o.SubElementNames:
print "name: ",s
for s in o.SubObjects:
print "object: ",s

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

# <type 'exceptions.AttributeError'>: 'Gui.SelectionObject' object has no attribute 'Label'
よろしくお願いいたします。
mrrclb48z
Posts: 27
Joined: Wed Feb 07, 2018 11:20 am

Re: マクロでラベルを出力する方法を教えて下さい

Postby mrrclb48z » Fri Feb 09, 2018 12:15 pm

o.ObjectNameできました
(参考)FreeCADのpythonマクロでTree viewをReport viewに表示 してみた
https://qiita.com/mrrclb48z/items/ad9d34390946bd0174a0