加载中…
个人资料
沙痕
沙痕
  • 博客等级:
  • 博客积分:0
  • 博客访问:262,701
  • 关注人气:326
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
博文
参考:
https://geonet.esri.com/thread/185176-convert-raster-dem-to-stl-for-3d-printing
http://gis.ess.washington.edu/data/vrml/vrml2stl.py

修改后,支持arcgis10.2,代码如下:

#! /usr/bin/env python
# Translates simple vrml to stl
# There is no support for textures.
# This has been tested on a large vrml file (representing topography) created
# by the tinvrml command in ARC/INFO 8.1, and running with 
# python 2.2.1 under solaris8 unix.
# The one argument is the root name of a .wrl file.
# The output is root.stl
# Version 1.1 does not stop at the first separator.
# Copyleft Harvey Greenberg, University of Washington, hgreen@u.washington.edu
import string
import sys

root = sys.argv[1]
print 'Converting ',root+'.wrl to ',root+'.stl'
f=open(root+'.wrl')
while 1:      # skip through initial stuff
  linney=string.split(f.readline())
# print linney
  if len(linney) == 4:
    if linney[0] == 'translation':
      transx = float(linney[1])
      transy = float(linney[2])
      transz = float(linney[3])
#     print 'xyz',transx,transy,transz # I don't use these values.
  #print linney
  #raw_input()
  if linney == ['point']:
    break
#print 'Reading vertex coordinates.'
skipline=f.readline()
verts = [] # The first triplet is index zero in the wrl file.
while 1:
  xyz = f.readline()
  linney=string.split(xyz)
  i = string.find(xyz,' ')
  if linney==[']']:    # end of vertex coordinates
    break
  else:
    verts.append(linney) # building a list of xyz strings
print 'We have',len(verts)-1,'vertices.'
while 1:     # skip to triplets of vertex numbers
  linney=string.split(f.readline())  # linney was a list, now it's a string
  if linney[0] == '[':
    break 
g=open(root+'.stl','w') # open stl file for writing.
g.write('solid %s\n' % root)
print 'Reading triangles.'
linney=f.readline()
#print linney
linney=linney.split('-1')
for row in linney:
  abc=string.split(row)
  if len(abc)<3:
  break
  else:
    #print abc[0]
    #print int(abc[0])
    xyz = verts[int(abc[0])] # look up a vertex in the list
    #print xyz
    #raw_input()
    x1 = float(xyz[0]) 
    y1 = float(xyz[1])
    z1 = float(xyz[2])
    xyz = verts[int(abc[1])]
    x2 = float(xyz[0])
    y2 = float(xyz[1])
    z2 = float(xyz[2])
    xyz = verts[int(abc[2])]
    x3 = float(xyz[0])
    y3 = float(xyz[1])
    z3 = float(xyz[2])

    dx1 = x1-x3
    dy1 = y1-y3
    dz1 = z1-z3
    dx2 = x2-x3
    dy2 = y2-y3
    dz2 = z2-z3
# print 'dx1=',dx1,'\ndy1=',dy1,'\ndz1=',dz1,'\ndx2=',dx2,'\ndy2=',dy2,'\ndz2=',dz2,'\n'
    vx = dy1*dz2 - dz1*dy2  # take the cross product of two edges
    vy = dz1*dx2 - dx1*dz2
    vz = dx1*dy2 - dy1*dx2
    templength = (vx*vx + vy*vy + vz*vz)**.5
    xn = vx/templength     # normalize the normal vector
    yn = vy/templength
    zn = vz/templength
# print 'Normal  %f,%f,%f\n' % (xn,yn,zn)

    g.write(' facet normal %f %f %f\n  outer loop\n' % (xn,yn,zn))
    g.write('   vertex %d %d %.2f\n' % (x1,y1,z1))
    g.write('   vertex %d %d %.2f\n' % (x2,y2,z2))
    g.write('   vertex %d %d %.2f\n' % (x3,y3,z3))
    g.write('  endloop\n endfacet\n')
g.write('endsolid %s\n' % root)
print 'Thank you.'



阅读    收藏 
标签:

信息化

决策支持系统

水利信息化

物联网

杂谈

分类: 水利模型、信息化
阅读    收藏 
标签:

excel

vba

杂谈

分类: 软件应用

参考:http://stackoverflow.com/questions/1026483/is-there-a-way-to-crack-the-password-on-an-excel-vba-project

 

以下方法经对office2003版测试通过.

  1. 先备份
  2. 利用HEX编辑器(http://mh-nexus.de/en/hxd/)打开excel文件,查找定位到 DPB=...
  3. 修改 DPB=... 为 DPx=...
  4. 保存文件,用excel打开
  5. 打开vba编辑器 (ALT+F11)
  6. 忽略安全提示
  7. 重新设置vba工程密码
  8. 保存 xls 文件
  9. 关闭,重新打开,输入新密码
阅读    收藏 
标签:

杂谈

分类: 软件应用

当CAD文档比较大时,要对其一些进行一些查找替换的工作时会非常费劲,可通过以下Lisp代码来解决。(此代码来源于:http://www.xdcad.net/forum/showthread.php?postid=3450490,因无法运行,本人就简单做了修改。类似的代码可参考:http://www.cadtutor.net/forum/showthread.php?14084-Find-amp-Replace-Text/page2&s=419b0d298de4ba28971450d224f1ac8ahttp://forums.augi.com/showthread.php?s=805bfed84067553b9ffb2c684187dfe4&t=30343

 

具体操作为:

1>将此代码粘贴至记事本保存,修改后缀名为.lsp;

2>根据自己的作业情况,如需要修改的CAD文件所在的文件夹路径; 

3>根据要修改的文字类型,参照代码里的注释进行修改(此处可通过代码完善,但本人也对lisp语言不熟,所以未做完善);

4>参照此加载该代码;“在AutoCAD中选择“工具”在下拉菜单中选择“Autolisp”,然后选择“加载程序”,然后选择你的××.lsp的程序在命令提示行里会显示加在成功,然后输入你程序里的命令就可以了!”

5>CAD命令行输入FR回车运行该程序,按照提示输入相应的参数值。

6>核查。

阅读    收藏 
标签:

河道

断面

河网密度

数学模型

数值模拟

水动力

水利

水力学

水文学

多目标

分类: 水利模型、信息化

    其他的话就不讲了,我觉得在考虑概化之前,先思考以下几个问题:

    1> 主要研究对象是否明确;

    2> 地形以及边界数据资料收集情况;

    3> 计算机硬件计算性能。

    明确了以上几个问题后,决定要不要概化,然后是用什么方法进行概化。概化是很玄乎的,含2种情况,将已知情况(已测量)概化和将未知情况(未测量或不可能去测量)概化,对前者需认真考虑,对后者不要浪费时间吹毛求疵,没有必要。对Mike11水动力数学模型来将,其概化方法如下图所示。

 

 

    通过实际案例计算来看,一般以最小空间步长50m,当前个人常规计算机来计算,则河网密度在1.5以上就需要进行概化,否则计算很慢,效率不高。对于大型河网的概化,如果真要一个个录入,工作量很大,建议通过读写断面文件进行程序处理,有两种思路:1是了解断面文件的程序接口,设定一些统计值到excel等文档,实现自动写入;2是将断面文件导出成txt(包含processed data导出),按该txt的相应规则写程序导入。

阅读    收藏 
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有