hello,
I have a web project, where I have to start solidworks an write into the custominfo fields.
The web project ist C# .net based and inside the intranet of the company.
my idea was to start sw with a vbscript function like this:
Function openSolidWorks()
Dim swApp
Dim Part
Dim success
Const ZeichnungsDatei = "\\FS8\Pl_Baugruppe.asmdot"
Set swApp = CreateObject("Sldworks.application")
Set SelMgr = Part.SelectionManager
if swApp <> null then
If Part Is Nothing Then
Set Part = swApp.NewDocument(ZeichnungsDatei, 0, 0, 0)
configname = Part.GetActiveConfiguration.Name
Part.DeleteCustomInfo2 configname, "PL_Maschinennr"
Part.DeleteCustomInfo2 configname, "PL_Index"
Part.DeleteCustomInfo2 configname, "PL_Artikelnr"
Part.DeleteCustomInfo2 configname, "PL_Bezeichnung"
Part.AddCustomInfo3 configname, "PL_Maschinennr", 30, "2104"
Part.AddCustomInfo3 configname, "PL_Index", 30, "01"
Part.AddCustomInfo3 configname, "PL_Artikelnr", 30, "210401"
Part.AddCustomInfo3 configname, "PL_Bezeichnung", 30, "newname"
swApp.ActiveDoc.ActiveView.FrameState = 1
Part.FileSummaryInfo
swApp.Visible = True
swApp.UserControl = True
success = "true"
' MsgBox "Part is nothing und NewDocument gestartet"
else
If (Part.GetType <> 2) Then
MsgBox "Eine Baugruppe muss aktiv sein!"
else
Part.DeleteCustomInfo2 configname, "PL_Maschinennr"
Part.DeleteCustomInfo2 configname, "PL_Index"
Part.DeleteCustomInfo2 configname, "PL_Artikelnr"
Part.DeleteCustomInfo2 configname, "PL_Bezeichnung"
Part.AddCustomInfo3 configname, "PL_Maschinennr", 30, "2104"
Part.AddCustomInfo3 configname, "PL_Index", 30, "01"
Part.AddCustomInfo3 configname, "PL_Artikelnr", 30, "210401"
Part.AddCustomInfo3 configname, "PL_Bezeichnung", 30, "newname"
swApp.ActiveDoc.ActiveView.FrameState = 1
Part.FileSummaryInfo
swApp.Visible = True
swApp.UserControl = True
MsgBox "Baugruppe ist aktiv"
End If
End If
else
MsgBox "Solidworks could not be starteted"
success = "false"
end if
openSolidWorks = success
end Function
The vbscript does not write into the custominfo with the AddCustomInfo3. When I use the same function within a makro, it works. Any Ideas?
Perhaps starting solidworks directy with a makro to write into the fileinfo with AddCustomInfo3?
SolidworksApi macros