小型实体建模库。
pysomo的Python项目详细描述
皮索莫
{1}$
pysomo(用于solidmodeling)是一个小型的实体建模库。此库允许您在Python中创建三维模型并将其导出为各种三维文件格式。在
要求
pysomo创建一个xcsg文件,xcsg应用程序可以解析该文件,从而以各种文件格式创建导出模型。pysomo不包括xcsg,可以单独下载:download xcsg。在
安装
- 要安装,只需运行
pip install pysomo
- 要从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)
这就产生了下面的硬币。在
楼梯
如果我们要使用允许的最大台阶高度,下面的规范将建造一个达到建筑规范允许的最大高度的楼梯。它通过代码演示建模。它还证明了在应用操作时,数字不会发生变化。相反,每个操作都返回一个新的数字。在
^{pr2}$这样就形成了下面的楼梯。在
这种三维建模风格的一个优点是通过变量更改模型的简单性。假设我们在允许的最大高度上加了一个零:
- 项目
标签: