几何尺寸与公差论坛

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

【转帖】assembly traversal modeldoc2.gettype problem

[复制链接]
发表于 2009-4-13 09:07:32 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-24 02:10 , Processed in 0.035436 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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