几何尺寸与公差论坛

 找回密码
 注册
查看: 1134|回复: 0

【转帖】can i import points data from excel

[复制链接]
发表于 2009-4-12 17:43:24 | 显示全部楼层 |阅读模式
can i import points data from excel?
howdy! i'm a solid work rookie and would like to know can i get some points datum in excel into solidworks.
i measured some points position with a laser tracker. now i want to analyze the lines and planes formed by these points. how can i get these data into solidworks and analyze them? or solidworks is not the right tool to do this kind of analysis?
insert, curve, curve through xyz points.
tips for working with this tool:
open an existing curve file. click browse and navigate to a curve file to open. you can open .sldcrv files or .txt files that use the same format as .sldcrv files. you can also create 3d curves in microsoft excel for example, save them as .txt files, then open them in solidworks. create a file containing coordinate values for curve points using a text editor or worksheet application. the file format must be a three-column, tab, or space-delimited list of only x, y, and z coordinates. do not include any column headings, such as x, y, and z or other extraneous data
deepak gupta
sw2007 sp5.0
sw2009 sp2.1
you can write a quick macro to create the points for you....
like open solidworks, make a new part and leave it on that screen, from excel vba do the following...
sub main()
dim part as object
dim selmgr as object
dim boolstatus as boolean
dim longstatus as long, longwarnings as long
dim feature as object
'this code starts sw from excel
set swapp = createobject("sldworks.application")
set modeldoc = swapp.activedoc
name = modeldoc.gettitle
'sets the window the model will be created in
set part = swapp.activatedoc2(name, false, longstatus)
set worksheet = worksheets("points") 'where points is name of sheet you are on...
with worksheet
part.insert3dsketch
finalgrid = .cells(65536, 3).end(xlup).row + 1
i = 2
do while i < finalgrid
part.createpoint2 .cells(i, 3).value, .cells(i, 4).value, .cells(i, 5).value
i = i + 1
loop
end with
end sub
that should run through the list of x,y,z coords that you have and make a 3d sketch with all the points in it of that....
column 3 = x points
column 4 = y points
column 5 = z points
oh yeah, sw internal units is millimeters, so if you have inches you might want to convert if you plan on scaling and such...
make sure to add the solidworks reference under tools in excel so it know what commands it needs to run...
edited: 02/11/2009 at 01:32 pm by adam hodge
thank you for the reply! it's very easy. however, when sw reads in the datum, it fits a curve automaticly. i cannot access to the points other than the two ends. how to change the curve back into points?
thank you for the detailed reply! i never used vba before, so can you give me more instruction?
i saved your script as a macros and change the " worksheets("points")" into "worksheets(1)" where i put my data. i ran it; nothing seems happen. what should i do?
and the "column 3 = x" points part, do you mean column a = x ? how to add the sw reference under tools in excel?
lots of beginer questions hehe. expecting your reply.
worksheets("points") refers to the name of the sheet the points are on. basically, replaced points with the name of the tab your data is on in excel.
example:
worksheets("sheet1")
this is be the default 1st sheet in a brand new excel file.
to add the reference, when in the macro editor (alt-f11 opens it) click the following
tools > references
then find the ones that say
solidworks 2007 constant type library
solidworks 2007 commands type library
place a check mark next to them and hit ok. (i have version 2007, this number will vary with what version you have)
finally, the column refers to what colum your data is in, column 3 in rc format is 3, or normal excel format would be column c. the vba references everything by column number not letter.
this program also has a header row for it, so it will start adding points at row 2 and continue until there is either no more rows (65,534 points) or no more points (any number up to 65,534 points)
that should get you to add the points to solidworks. it will be in a single 3d sketch, if you wanted, you can make a new sketch for each point, but solidworks will get slow after you have a couple thousand sketches..
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 18:39 , Processed in 0.034404 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表