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

Japanese forum
Post Reply
mrrclb48z
Posts: 54
Joined: Wed Feb 07, 2018 11:20 am

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

Post by mrrclb48z »

# -*- 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: 54
Joined: Wed Feb 07, 2018 11:20 am

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

Post by mrrclb48z »

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