-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@command
def unify_parm_block_charact():
# 统一参数块的参数特性
db = Db.curDb()
# current_layer = Db.LayerTableRecord(get_current_layer_id(db))
try:
times = 0
flag_has_block = False
while True and times < 10:
print("请选择源参数块")
blocks_list = get_select_blocks_id()
if blocks_list == "Canel" or not isinstance(blocks_list, list):
return
if len(blocks_list) != 1:
print(f"请选择单块")
times += 1
continue
else:
flag_has_block = True
break
if not flag_has_block:
return
# 读取 源目标参数块的参数特性
ref_param_block = Db.BlockReference(blocks_list[0])
btr = Db.BlockTableRecord(ref_param_block.blockTableRecord())
if not btr.hasAttributeDefinitions(): # 参数块
print(f"选入的目标源块 不是参数块或没有参数属性")
return
ref_dict = {}
attIds = ref_param_block.attributeIds()
for attid in attIds:
attref = Db.AttributeReference(attid)
# print(f"attref {attref.tag()}, text: {attref.textString()}, textstyle: {attref.textStyle()}")
textstyle = Db.TextStyleTableRecord(attref.textStyle())
# textstyle = Db.TextStyleTable(attref.textStyle())
ref_dict[attref.tag()] = attref.textStyle()
print(f"attref tag: {attref.tag()}, text: {attref.textString()}, textstyle: {attref.textStyle()}")
print(f"textstyle: {textstyle.fileName()}")
# # textstyle
print(f" text flagBits: {textstyle.flagBits()}")
print(f"font : {textstyle.font()}")
print(f"obliquingAngle: {textstyle.obliquingAngle()}")
print(f"priorSize: {textstyle.priorSize()}")
return can not find |
Beta Was this translation helpful? Give feedback.
-
Both AttributeDefinition and AttributeReference derived from Db.Text and should have the same properties import traceback
from pyrx import Ap, Ax, Db, Ed, Ge, Gi, Rx
@Ap.Command()
def doit() -> None:
try:
db = Db.curDb()
bt = Db.BlockTable(db.blockTableId())
for name, id in bt.toDict().items():
if name != "GRA":
continue
blkrec = Db.BlockTableRecord(id)
if not blkrec.hasAttributeDefinitions():
continue
# first do the the definitions
defids = blkrec.objectIds(Db.AttributeDefinition.desc())
for defid in defids:
attdef = Db.AttributeDefinition(defid)
print(
"\nDEF!",
attdef.tag(),
attdef.height(),
attdef.rotation(),
attdef.widthFactor(),
attdef.oblique(),
)
style = Db.TextStyleTableRecord(attdef.textStyle())
print(
"\nSTYLE for DEF!",
style.name(),
style.textSize(),
style.font(),
)
break
# next, just do one att ref
for refid in blkrec.getBlockReferenceIds():
blkref = Db.BlockReference(refid)
for attid in blkref.attributeIds():
attref = Db.AttributeReference(attid)
print(
"\nREF!",
attref.tag(),
attref.height(),
attref.rotation(),
attref.widthFactor(),
attref.oblique(),
)
print(
"\nSTYLE for REF!",
style.name(),
style.textSize(),
style.font(),
)
return
except Exception as err:
traceback.print_exception(err) I hope this get you what you need? |
Beta Was this translation helpful? Give feedback.
-
Glad it worked! I would like to know your experience using PyCharm, can you see the class hierarchy? ![]() |
Beta Was this translation helpful? Give feedback.
Both AttributeDefinition and AttributeReference derived from Db.Text and should have the same properties
using drawing PyRxGit\tests\media\06457.dwg