pythonocc_特征显示

在这里插入图片描述
在这里插入图片描述

import sys
from OCC.Core.gp import gp_Pnt
from OCC.Core.Geom import Geom_CartesianPoint
from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB
from OCC.Core.Aspect import (Aspect_TOM_POINT,Aspect_TOM_PLUS,Aspect_TOM_STAR,Aspect_TOM_X,Aspect_TOM_O,Aspect_TOM_O_POINT,Aspect_TOM_O_PLUS,Aspect_TOM_O_STAR,
                            Aspect_TOM_O_X,Aspect_TOM_RING1,Aspect_TOM_RING2,Aspect_TOM_RING3,Aspect_TOM_BALL)

from OCC.Core.AIS import AIS_Point
from OCC.Core.Prs3d import Prs3d_PointAspect, Prs3d_Drawer
from OCC.Display.SimpleGui import init_display



def pnt():
    ALL_ASPECTS = [Aspect_TOM_POINT, Aspect_TOM_PLUS, Aspect_TOM_STAR, Aspect_TOM_X, Aspect_TOM_O,
                   Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS, Aspect_TOM_O_STAR, Aspect_TOM_O_X,
                   Aspect_TOM_RING1, Aspect_TOM_RING2, Aspect_TOM_RING3, Aspect_TOM_BALL]
    import math
    # create a point
    for idx in range(10):
        x = 0 + math.sin(idx * 0.1*3.14 )
        for idy in range(10):
            y = 0 + math.cos(idy * 0.1*3.14 )
            for idz, aspect in enumerate(ALL_ASPECTS):#枚举
                z = 0 + idz / len(ALL_ASPECTS)
                p = Geom_CartesianPoint(gp_Pnt(x, y, z))#设置点的位置
    '''for idx in range(60):
        x = 0 + 10*math.sin(idx * 0.1 +1)
        for idy in range(60):
            y = 0 + 5*math.sin(idy * 0.1+5 )
            for idz, aspect in enumerate(ALL_ASPECTS):#枚举
                z = 0 + idz / len(ALL_ASPECTS)
                p = Geom_CartesianPoint(gp_Pnt(x, y, z))#设置点的位置'''
    # for idx in range(10):
    #     for idy in range(10):
    #         for idz, aspect in enumerate(ALL_ASPECTS):  # 枚举
    #             x = 0 + idx * 0.1
    #             y = 0 + idy * 0.1
    #             z = 0 + idz / len(ALL_ASPECTS)
    #             p = Geom_CartesianPoint(gp_Pnt(x, y, z))  # 设置点的位置

                # color = Quantity_Color(x / len(ALL_ASPECTS), 0, z, Quantity_TOC_RGB)#颜色
                color = Quantity_Color(x / len(ALL_ASPECTS),0.5, z, Quantity_TOC_RGB)  # 颜色
                ais_point = AIS_Point(p)#将点设置为AI是
                drawer = ais_point.Attributes()#定义画笔属性
                asp = Prs3d_PointAspect(aspect, color, 3)# 特征、颜色
                drawer.SetPointAspect(asp)#画笔设置
                ais_point.SetAttributes(drawer)#画笔加载
                display.Context.Display(ais_point, False)

    display.FitAll()
    start_display()

def exit(event=None):

    sys.exit()

if __name__ == '__main__':
    display, start_display, add_menu, add_function_to_menu = init_display()
    pnt()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值