几何尺寸与公差论坛

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

【转帖】cosmosworks macro using ms visual c==

[复制链接]
发表于 2009-4-13 09:57:28 | 显示全部楼层 |阅读模式
cosmosworks macro using ms visual c++
hello all,
i am trying to setup an instance of the cosmosworks object to write a macro. i have the solidworks application object ready and usable, i just can't figure out how to do it for the cosmosworks object. if someone has any knowledge, any at all, i would greatly appreciate the help.
brendan leahy
add a reference to cosmosworkslib
dim cw as cosmosworks
dim cwo as object
dim cwmodel as cwmodeldoc
dim cwstudymgr as cwstudymanager
dim cwstudy as cwstudy
dim errcode as long
' presuming the cosmosworks dll has been loaded...
set cwo = swapp.getaddinobject("cosmosworks.cosmosworks")
if cwo is nothing then
' error here
end if
set cw = cwo.cosmosworks
set cwmodel = cw.activedoc()
set cwstudymgr = cwmodel.studymanager()
if cwstudymgr is nothing then
' error here
end if
set cwstudy = cwstudymgr.createnewstudy("my static study name", 0, cwmixedelementmesh, errcode)
if cwstudy is nothing then
' error here
end if
' and define your enums like so...
public enum cwanalysistype
cwstaticanalysis = 0
cwfrequencyanalysis = 1
cwbucklinganalysis = 2
cwthermalanalysis = 3
cwnonlinearanalysis = 5
end enum
public enum cwmeshelementtype
cwsolidelementmesh = 0
cwmidsurfshellelementmesh = 1
cwrefsurfshellelementmesh = 2
cwmixedelementmesh = 3
cwbeamelementmesh = 4
cwpointelementmesh = 5
end enum
public enum cwrestrainttype
cwrestraintfixed = 0
cwrestraintimmovable = 1
cwrestraintsymmetric = 2
cwrestraintrollersupport = 3
cwrestrainthinge = 4
cwrestraintcomponents = 5
cwrestraintflatsurf = 6
cwrestraintcylindricalsurf = 7
cwrestraintsphericalsurf = 8
cwrestraintcyclicsymmetry = 9
end enum
and so on. i think you get the general idea see how you go with that first
awesome, thank you for helping, though i should have stated that i was working in c++. nonetheless, i am grateful for your help. i have a couple questions about possibly writing this in c++. how does one reference the cosmosworks library in visual c++? do you know the name of the file i need to reference? is there a *.h file i need to include in my function to get it to work?
just use the #import statement and import the following file:
c:\program files\solidworks\cosmosworks\cosworks.tbl
wow... so thats the file.. i looked through my folder structure and i don't have it. i currently have cosmosworks sp 0.0. could that be the problem? i am guessing that if anything that it is on a later service pack?
brendan
p.s. you have been the most significant help i have had on this subject. thank you!
you should have the file. try a search on the c:\program files folder for ".tbl" and take a look at all library files that appear. it may be in a different location based on your os or install.
hrmm.... i don't seem to have it at all. is there a place i could go and download it? is it on the install disk?
nevermind.... i actually got it... thank you again for all the help you gave me.
brendan leahy
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-24 10:00 , Processed in 0.035623 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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