几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 09:07 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】assembly traversal modeldoc2.gettype problem

assembly traversal modeldoc2.gettype problem
i am traversing through the assembly tree. i am looking at the children in the assembly. if the child component is an assembly, i would like to perform a certain procedure. if it is a part, then i need it to do something else. i tried to apply typical logic to this and i just can't get it to work. i am trying to get the file type of the child.
for this line (swchildcomp.gettype = swdocpart) i am getting the following error.
operator '=' is not defined for types 'system.type' and 'integer'.
in my program i have tried everything. here is what i have so far:
vb.net code
public class editor
public enum swdocumenttypes_e
swdocnone = 0 ' used to be type_none
swdocpart = 1 ' used to be type_part
swdocassembly = 2 ' used to be type_assembly
swdocdrawing = 3 ' used to be type_drawing
end enum
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swassy as sldworks.assemblydoc
dim swconf as sldworks.configuration
dim swrootcomp as sldworks.component2
dim bret as boolean
dim swchildcomp as sldworks.component2
dim swcompconfig as sldworks.configuration
dim spadstr as string
dim mo as integer
dim moddoc as object
sub traversecomponent(byval swcomp as sldworks.component2, byval nlevel as long)
dim vchildcomparr as object
dim vchildcomp as object
dim swchildcomp as sldworks.component2
dim supstate as long
programstatus.text = "adding components"
statusstrip1.refresh()
vchildcomparr = swcomp.getchildren
for each vchildcomp in vchildcomparr
swchildcomp = vchildcomp
moddoc = swchildcomp.getmodeldoc
supstate = swchildcomp.getsuppression
if (swchildcomp.gettype = swdocassembly) then 'process assemblies
'do something here
end if
if (swchildcomp.gettype = swdocpart) then 'process parts only
'do something else here
end if
datagridview1.refresh()
traversecomponent(swchildcomp, nlevel + 1)
next
end sub
end class
any help is appreciated.
tony szuta
cswa, cswp, cswp-smtl
would it work to use component.getpathname and examine the right most letter? " w" is drawing, "m" is assembly, and "t" is prt.
dan miel
tony,
without all of the code, i cannot verify that this will work. change your "dim vchildcomparr as object" to "dim vchildcomparr() as object"
this is one of the issues in conversion from vb6 or vba to vb.net. vb.net does not allow variants and vchildcomparr in vba returns an array of component2 objects. this will declare vchildcomparr as a dynamic array of objects.
wayne matus
texas engineering systems
dan,
this is the work around that i am currently using. i am just wondering if this will cause any issues on machines that do not display file extensions.
wayne,
i really don't have much more code as of yet.
trying your suggestion, i still get the same problem.
error list
error 1 operator '=' is not defined for types 'system.type' and 'integer'.
thanks guys.
tony szuta
cswa, cswp, cswp-smtl
answer figured it out.
i changed
dim moddoc as object
to
dim moddoc as sldworks.modeldoc2
and changed
if (swchildcomp.gettype = swdocassembly)
to
if moddoc.gettype() = swdocassembly
tony szuta
cswa, cswp, cswp-smtl
intel core2 quad (q6600 @ 2.40 ghz)
nvidia quadro fx 4600 sdi
solidworks 2008 sp 4.0 (x32 & x64)
solidworks 2009 sp 2.0 (x32 & x64)
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】sketchblockdefinition problem yang686526 SolidWorks二次开发 0 2009-04-12 07:37 PM


所有的时间均为北京时间。 现在的时间是 05:45 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多