jinzhifenlie 发表于 2022-3-31 10:24:14

python脚本

有哪位大佬熟悉python语言吗?请问下文这篇优化案例中的python脚本是什么意思?

def main():
        model_id = 0
        all_resultsets = results.Resultsets(model_id)
        result = all_resultsets[-1]
        part_type = constants.PSHELL
        part1_nodes = nodes.NodesOfPart(model_id, part_type, 1)
        part6_nodes = nodes.NodesOfPart(model_id, part_type, 6)
        for n in part1_nodes:
                if nodes.CoordinatesOfNode(result, n.id).y < 9.7:
                        if nodes.CoordinatesOfNode(result, n.id).x > node1_x:
                                node1_x = nodes.CoordinatesOfNode(result, n.id).x
                                node1_id = n.id
        for n in part6_nodes:
                if nodes.CoordinatesOfNode(result, n.id).x > 3.12 and nodes.CoordinatesOfNode(result, n.id).y > 7.85:
                        if nodes.CoordinatesOfNode(result, n.id).x < node6_x:
                                node6_x = nodes.CoordinatesOfNode(result, n.id).x
                                node6_id = n.id
        dis = node1_x -node6_x
if __name__ == '__main__':
        main()


优化案例原文:
https://mp.weixin.qq.com/s?__biz=MzAxODIzOTE3NQ==&mid=2247487365&idx=1&sn=3d21108cc232e9fd564ac75d4a3859de&chksm=9bd8142dacaf9d3bf616c1ce384e9f4dbee3a884dc777998390f4ff80ef75830045a96598b01&mpshare=1&srcid=0314ZOCbPKFPVMqXXafYZrBM&sharer_sharetime=1647227358323&sharer_shareid=d2376663a3df5340a5b03fc225d98949&from=singlemessage&scene=1&subscene=10000&clicktime=1648693075&enterid=1648693075&ascene=1&devicetype=android-30&version=28001455&nettype=ctnet&abtest_cookie=AAACAA%3D%3D&lang=zh_CN&exportkey=ARnUpO3S69e6u6dytuz%2FvSg%3D&pass_ticket=g9lhCO3HwCgaK5XkDgMAj4HOnt7f8wQk2CwDuDzeOYFdaq5I7n7jcYGUW6yNcyJ1&wx_header=3

jinzhifenlie 发表于 2022-3-31 10:26:25

model_id指的是part id吗?results.Resultsets指的又是什么

爱学习的人 发表于 2022-4-1 19:56:36

应该是计算part1中各节点最大的X轴坐标与part6各节点最小的X轴坐标之间的差值。
results.Resultsets直接学着调用就可以。
页: [1]
查看完整版本: python脚本