|
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 |
|