Home > Software engineering >  SolidWorks macro is VB language, can use it to query for the return value of a database? thank you
SolidWorks macro is VB language, can use it to query for the return value of a database? thank you

Time:11-10

Database has been had, there are tables, my side has a DH interface input field, the return value for BM, can be invoked by VB, without him the interface implementation? Thank you
Address: database 192.168.1.101
The database type: former
User name: DZHT
Password: DZHT
Data sheets: partdic
Input code fields: dh (to be automatic access to VB code value)
The generated code field: bm
The following is the inside of the SolidWorks macro file:
'definition of SolidWorks
Dim strmat As String
Dim (a) As String
Dim As Integer b
Dim c As String
Dim d As a String
Dim e As String
Dim f As String
Dim g () As String
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim tempvalue As String
Dim part As Object
Dim Part1 As Object
Dim swApp As SldWorks. SldWorks
Dim swModelDoc As SldWorks. ModelDoc2
Dim swConfig As SldWorks. Configuration
Dim CustPropMgr As SldWorks. CustomPropertyManager
Dim swModel As SldWorks. ModelDoc2
Sub main ()
The Set swApp=Application. SldWorks
The Set swModelDoc=swApp. ActiveDoc
The Set part=swApp. ActiveDoc
The Set SelMgr=part. SelectionManager
SwApp. ActiveDoc. ActiveView. FrameState=1
The Set swModelDoc=swApp. ActiveDoc
The Set swConfig=swModelDoc. ConfigurationManager. ActiveConfiguration
The Set swModel=swApp. ActiveDoc
The Set CustPropMgr=swModel. The Extension. CustomPropertyManager swModel. ConfigurationManager. ActiveConfiguration. (Name) 'configuration specific extends
'set the variable
The Set part=swApp. ActiveDoc
The Set SelMgr=part. SelectionManager
SwApp. ActiveDoc. ActiveView. FrameState=1
The Set swModelDoc=swApp. ActiveDoc
The Set swConfig=swModelDoc. ConfigurationManager. ActiveConfiguration
The Set swModel=swApp. ActiveDoc
The Set CustPropMgr=swModel. The Extension. CustomPropertyManager swModel. ConfigurationManager. ActiveConfiguration. (Name) 'configuration specific extends
'set the variable
C=swApp. ActiveDoc. GetTitle () 'parts name
B=swApp. ActiveDoc. GetType () 'parts type
A=Split (c, "") 'key: separate the identifier, here is a space, can be replaced with other symbols
D=a (0) ' (this is to want to enter the database value is dh, want to get a return value bm, fill in remark)
E=a (1)
F=Right (c, 7)
If b=1 Then
Strmat1=CRH (34) + Trim (" SW - Mass "+" @ "+" @ @ "by default) + c +" SLDPRT "+ CRH (34) 'Weight
Strmat=CRH (34) + Trim (" SW - Material "+" @ "+" @ @ "by default) + c +" SLDPRT "+ CRH (34) 'Material
W="/"
The Else
Strmat="chart"
Strmat1=CRH (34) + Trim (" SW - Mass "+" @ "+" @ @ "by default) + c +" SLDASM "+ CRH (34) 'Weight
W="component"
End the If
If f="SLDPRT" Then
G=Split (e, ". ")
E=g (0)
End the If
If f="SLDPRT" Then
G=Split (e, ". ")
E=g (0)
End the If

If f="SLDASM" Then
G=Split (e, ". ")
E=g (0)
End the If
If f="sldasm" Then
G=Split (e, ". ")
E=g (0)
End the If

Blnretval=part. DeleteCustomInfo2 (" ", "code")
Blnretval=part. DeleteCustomInfo2 (" ", "design")
Blnretval=part. DeleteCustomInfo2 (" ", "name")
'blnretval=part. DeleteCustomInfo2 (" ", "code")
Blnretval=part. DeleteCustomInfo2 (" ", "material")
Blnretval=part. DeleteCustomInfo2 (" ", "specifications")
Blnretval=part. DeleteCustomInfo2 (" ", "number")
Blnretval=part. DeleteCustomInfo2 (" ", "Specification")
Blnretval=part. DeleteCustomInfo2 (" ", "single")
Blnretval=part. DeleteCustomInfo2 (" ", "quality")
Blnretval=part. DeleteCustomInfo2 (" ", "drawing")
Blnretval=part. DeleteCustomInfo2 (" ", "approval")
Blnretval=part. DeleteCustomInfo2 (" ", "date")
Blnretval=part. DeleteCustomInfo2 (" ", "check")
Blnretval=part. DeleteCustomInfo2 (" ", "alternative")
Blnretval=part. DeleteCustomInfo2 (" ", "map")
Blnretval=part. DeleteCustomInfo2 (" ", "version")
Blnretval=part. DeleteCustomInfo2 (" ", "remarks")
Blnretval=part. DeleteCustomInfo2 (" ", "review")
Blnretval=part. DeleteCustomInfo2 (" ", "Material")
B lnretval=part. DeleteCustomInfo2 (" ", "part number")
Blnretval=part. DeleteCustomInfo2 (" ", "check")
Blnretval=part. DeleteCustomInfo2 (" ", "competent design")
Blnretval=part. DeleteCustomInfo2 (" ", "check")
Blnretval=part. DeleteCustomInfo2 (" ", "Weight")
Blnretval=part. DeleteCustomInfo2 (" ", "Description")
Blnretval=part. DeleteCustomInfo2 (" ", "standard review")
Blnretval=part. DeleteCustomInfo2 (" ", "technology review")
Blnretval=part. DeleteCustomInfo2 (" ", "approved")
Blnretval=part. DeleteCustomInfo2 (" ", "phase marker S")
Blnretval=part. DeleteCustomInfo2 (" ", "stage marks A")
Blnretval=part. DeleteCustomInfo2 (" ", "stage mark B")
Blnretval=part. DeleteCustomInfo2 (" ", "stage tag")
Blnretval=part. DeleteCustomInfo2 (" ", "total X zhang")
Blnretval=part. DeleteCustomInfo2 (" ", "X" zhang)

'
delete columnCustPropMgr. Delete (" name ")
CustPropMgr. Delete (" design ")
CustPropMgr. Delete (" drawing ")
CustPropMgr. Delete (" materials ")
CustPropMgr. Delete (" code ")
CustPropMgr. Delete (" device name ")
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related