小型实体建模库。

pysomo的Python项目详细描述


皮索莫

{1}$ Tests

pysomo(用于solidmodeling)是一个小型的实体建模库。此库允许您在Python中创建三维模型并将其导出为各种三维文件格式。在

要求

pysomo创建一个xcsg文件,xcsg应用程序可以解析该文件,从而以各种文件格式创建导出模型。pysomo不包括xcsg,可以单独下载:download xcsg。在

安装

  1. 要安装,只需运行pip install pysomo
  2. 要从xcsg格式导出到三维模型文件,xcsg application必须与应用程序位于同一目录中。在

示例

挤压

下面的代码创建了一个中间有方孔的硬币。在

importpysomoassomo# First let's create the round part of the coin.coin_circle=somo.Circle(30)# This creates the base solid of the coin.coin=coin_circle.linear_extrude(2)# Create the solid to use as the extrusion. Note that we use the offset method# to create a smaller circle from the base. This will give us the rim.coin_extr=coin_circle.offset(-5,True).linear_extrude(1)# Now we use the subtraction operator to extrude our shapes from the coin.coin=coin-coin_extr.translate(0,0,1.5)-coin_extr.translate(0,0,-0.5)# Let's now create the square hole in the coin.square=somo.Square(20)square_rim=square.linear_extrude(2)square_hole=square.offset(-2,False).linear_extrude(2)# Our final coin is the base coin with a square removed.coin=coin+square_rim-square_hole# Now we export to a file. The Root is responsible for building the xcsg file.root=somo.Root(coin)# The Exporter reads the root file and uses the xcsg application.somo.Exporter(r"coin.obj").export_obj(root)

这就产生了下面的硬币。在

Extrusion solid

楼梯

如果我们要使用允许的最大台阶高度,下面的规范将建造一个达到建筑规范允许的最大高度的楼梯。它通过代码演示建模。它还证明了在应用操作时,数字不会发生变化。相反,每个操作都返回一个新的数字。在

^{pr2}$

这样就形成了下面的楼梯。在

Stairs

这种三维建模风格的一个优点是通过变量更改模型的简单性。假设我们在允许的最大高度上加了一个零:

Stairs

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将cassandra中的行数据转换为与列相关的嵌套json   java如何使用jcr XPath在jcr:content/@jcr:data中搜索?   java在使用openCV进行安卓开发时如何利用手机的广角镜头   java解析扩展了接口,结束了一个潜在的无限循环   位置服务的@Override方法中存在java Android应用程序错误   java本地线程的用途和需求是什么   具有左右子访问的java节点树遍历   java验证JsonWebToken签名   JUL日志处理程序中的java日志记录   嵌入式Java读取给定时间段的串行数据。   java有没有办法从多个URL获取多个图像?   java线程通过等待intent阻止自己发送intent   java Spring MVC解析多部分内容请求   java JPA/Hibernate静态元模型属性未填充NullPointerException   java格式错误的字符(需要引号,得到I)~正在处理   java为什么PrintWriter对象抛出FileNotFoundException?   java Neo4j未正确保存标签   java IE不加载图像