SolidWorks two times development--10--from the example search

Source: Internet
Author: User

SolidWorks API Help is still very comprehensive, there are many see simple and effective procedures, all day in the API help bubble, and now the speed of the program is faster. It's like I've been recording macros in Excel all day long to see the code. The following program is in the API help to show all parts of the assembly. I use it for my colleagues, they feel good:). The program uses a simple recursive method to traverse the assembly.
Make all Assembly components Visible Example (VB)
This example shows the "How to" all assembly components visible.



'---------------------------------------

'

' Preconditions:an assembly document is open.

'

' Postconditions:any hidden assembly components are made.

'

'---------------------------------------

Option Explicit

Public Enum Swcomponentvisibilitystate_e

}}-->}}-->swcomponenthidden = 0

}}-->}}-->swcomponentvisible = 1

End Enum



Sub Traversecomponent _

( _

}}-->}}-->swcomp as Sldworks.component2, _

}}-->}}-->nlevel as Long _

)

}}-->}}-->dim Vchildcomparr}}-->}}-->as Variant

}}-->}}-->dim vchildcomp}}-->}}-->as Variant

}}-->}}-->dim swchildcomp}}-->}}-->as sldworks.component2

}}-->}}-->dim swcompconfig}}-->}}-->as sldworks.configuration

}}-->}}-->dim spadstr}}-->}}-->as String

}}-->}}-->dim i}}-->}}-->as Long

}}-->}}-->

}}-->}}-->for i = 0 to NLevel-1

}}-->}}-->spadstr = spadstr + "}}-->}}-->"

}}-->}}-->next I

}}-->}}-->

}}-->}}-->vchildcomparr = Swcomp.getchildren

}}-->}}-->for each vchildcomp in Vchildcomparr

}}-->}}-->set Swchildcomp = Vchildcomp

}}-->}}-->

}}-->}}-->debug.print spadstr & swchildcomp.name2 & "<" & Swchildcomp.referencedconfiguratio N & ">"

}}-->}}-->

}}-->}}-->if Swcomponenthidden = swchildcomp.visible Then

}}-->}}-->swchildcomp.visible = swcomponentvisible

}}-->}}-->end If

}}-->}}-->

}}-->}}-->traversecomponent Swchildcomp, Nlevel + 1

}}-->}}-->next

End Sub



Sub Main ()

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

}}--> Set Swapp = Application.sldworks

}}-->}}-->set Swmodel = Swapp.activedoc

}}-->}}-->set swconf = swmodel.getactiveconfiguration

}}-->}}-->set Swrootcomp = swconf.getrootcomponent}}-->}}-->

}}-->}}-->debug.print "File =" & Swmodel.getpathname

}}--> traversecomponent Swrootcomp, 1

End Sub


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.