こちらの続きです。
トリム前後で同一の線と判断したい1 - C#ATIA
早速、属性が引き継がれるんじゃないかな?テストコード。
# Fusion360API Python script import traceback import adsk.fusion import adsk.core def run(context): ui: adsk.core.UserInterface = None try: app: adsk.core.Application = adsk.core.Application.get() ui = app.userInterface des: adsk.fusion.Design = app.activeProduct root: adsk.fusion.Component = des.rootComponent skt: adsk.fusion.Sketch = root.sketches.add( root.xYConstructionPlane ) circles: adsk.fusion.SketchCircles = skt.sketchCurves.sketchCircles cir1: adsk.fusion.SketchCircle = circles.addByCenterRadius( adsk.core.Point3D.create(1,1,0), 2.0 ) cir1.attributes.add( 'testGroup', 'hoge', 'piyo' ) cir2: adsk.fusion.SketchCircle = circles.addByCenterRadius( adsk.core.Point3D.create(2,2,0), 1.0 ) app.log('TextCommandWindow.Clear') dumpInfo(cir1) tools: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create() tools.add(cir2) res = cir1.trim( adsk.core.Point3D.create(3,3,0), ) dumpInfo(cir1) ark1 = res.item(0) dumpInfo(ark1) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) def dumpInfo(sktEnt: adsk.fusion.SketchEntity) -> None: def isVisible(sktEnt: adsk.fusion.SketchEntity) -> bool: try: if not hasattr(sktEnt, 'isVisible'): return False return sktEnt.isVisible except: return False def getToken(sktEnt: adsk.fusion.SketchEntity) -> str: try: return sktEnt.entityToken except: return '' def getAttrsStr(ent) -> str: try: if not hasattr(ent, 'attributes'): return '' attrs: adsk.core.Attributes = ent.attributes if attrs.count < 1: return '' attr: adsk.core.Attribute lst = [] for gpName in attrs.groupNames: lst.append(f' GroupName : {gpName}') for attr in attrs.itemsByGroup(gpName): lst.append(f' {attr.name}:{attr.value}') return '\n'.join(lst) except: return '' # ********* msg = '-------\n' msg += f'classType | {sktEnt.classType()}\n' msg += f'isVisible | {isVisible(sktEnt)}\n' msg += f'token | {getToken(sktEnt)}\n' msg += f'attrs | \n{getAttrsStr(sktEnt)}\n' adsk.core.Application.get().log(msg)
結果はこちら。
------- classType | adsk::fusion::SketchCircle isVisible | True token | /v4BAAAARlJLZXkAH4sIAAAAAAAA/zNQsFAwAEJDBSMgBrOMLIAsQwUTkIiZQpZUsctTXQ/5Tb+ly/8sv1sFVGGkYGymYG5qkWJikGaua5pikqZrYmBpomtpYZCka5RiYWZmYmhmlGpgAlYLNIMBDYDtM1AAW2dqaASx1hyo1ADIBgChA1jrkgAAAA== attrs | GroupName : testGroup hoge:piyo ------- classType | adsk::fusion::SketchCircle isVisible | False token | attrs | ------- classType | adsk::fusion::SketchArc isVisible | True token | /v4BAAAARlJLZXkAH4sIAAAAAAAA/zNQsFAwAEJDBSMgBrOMLIAsQwUTkIiZQpZUsctTXQ/5Tb+ly/8sv1sFVGGkYGymYG5qkWJikGaua5pikqZrYmBpomtpYZCka5RiYWZmYmhmlGpgAlYLNIMBDYDtM1AAW2dqaASx1hyo1ACELQDvwUqZlAAAAA== attrs |
ふぅ、結論無理。