广义模块化设计的脚本编程实现:基于OpenSCAD的参数化框架与元结构建模

框架与元结构在机床等大件结构上广泛应用,通常采用Creo等三维参数化CAD系统进行设计建模,并用利用Ansys等有限元分析软件进行静动态分析。广义模块化设计是基于参数化模块与元结构的模块化设计方法。本文尝试采用OpenSCAD进行参数化、模块化建模,通过脚本编程方式建立参数化模块库,进一步根据设计要求,通过脚本编程方式实现模块的位置变换和组合。

 主要步骤如下:

1. 建立参数化元结构模型

//参数化元结构参数
//cell_height=100 边长
//cell_thick=15  壁厚
module cell(height,thickness) {

 difference() {
   // cube(height,center=true);
    cube([height,height,height],center=true);
    //cube([side,side,thickness]); 
     cube(height-2*thickness,center=true);
    //sphere(height-2*thickness);
    //translate([0,0,-height/2]) 
    cylinder(height+0.02,height/2-thickness,height/2-thickness,center=true);
     rotate([90,0,0])  cylinder(height+0.02,height/2-thickness,height/2-thickness,center=true);
      rotate([0,90,0])   cylinder(height+0.02,height/2-thickness,height/2-thickness,center=true);
    }
 
}

元结构图形如下:


 

2.建立框架结构模块模型

1.1 箱体类框架

//参数化箱体类框架模块参数
//length=300;//长
//width =400;//宽
//height = 200;//高
module FrameBox(length,width,height,cell_height,cell_thick) {

nL=length/cell_height;
nW=width/cell_height;
nH=height/cell_height;

  for (i=[0:1:nL]) {
  for (j=[0:1:nW]) {
   // r = 0 + j*cell_height;
   // n = cell_height + cell_height*j;
    //  n=width/cell_height;
    // step = cell_height;
    for (k=[0:1:nH]) {
        dx = i*cell_height;
        dy = j*cell_height;
        dz = k*cell_height;
        translate([dx,dy,dz])            
        cell(cell_height,cell_thick);;
    }
 }
 }
 }//module box

1.2 回转类框架

//参数化回转类框架尺寸
//out_diameter=500;//外径
//in_diameter=300;//内径
//height =400;//高
 module FrameTurn(out_diameter,in_diameter,height,cell_height,cell_thick) {
 
nR=(out_diameter/2-in_diameter/2)/cell_height+1;
nH=height/cell_height;
 for (k=[0:1:nH]) 
 {
  dz = k*cell_height;
 for (j=[0:1:nR]) {
    r = in_diameter/2 + j*cell_height;
    step=(cell_height/(2*3.1415926*(r+cell_height)))*360;
    for (angle=[0:step:359]) {
        dx = r*cos(angle);
        dy = r*sin(angle);
        translate([dx,dy,dz])
            rotate(angle)
            cell(cell_height,cell_thick);;
    }
}
}
}//module rot

3. 实例化应用

 以铣齿机床身结构为例,利用上述参数化的框架模块,可快速生成床身模型。

//元结构参数实例
cell_height = 100; //边长
cell_thick   = 15; //壁厚
 
//箱体类框架实例
length=500;//长
width =300;//宽
height = 200;//高
FrameBox(length,width,height,cell_height,cell_thick);
 
 //回转类框架实例
out_diameter=300;//外径
in_diameter=250;//内径
height2 =200;//高
translate([length+out_diameter/2,width/2,0]) 
 FrameTurn(out_diameter,in_diameter,height2,cell_height,cell_thick);

输出图形如下

4. 实现环境说明

操作系统:国产统信UOS 20操作系统(家庭版21)

OpenSCAD:源码编译,2023.1.9

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值