DohPee
Computer
- Jun 25, 2002
- 12
I use Solidworks 2001 SP 14.
I am trying to use the dsofile.dll from Microsoft to read the custom properties from a file that is referenced by a drawing. But it says it cannot get the info as the file is open?.
ie. I have a drawing (drw) open in solidworks and my app can see the drawing and its custom props using custominfo but when I get the dependant document path for the assembly (asm) and try to receive the custominfo using dsofile it says the file is already open/in use. But as far as i can see in SWX only the drawing is open?
Anybody got any other ideas on getting the custom properties from the referenced assembly(non configuration specific).
:
eg.
Drawing = assem1.slddrw
Assembly = assem1.sldasm
Drawing was created from Assembly using drag drop in SWX.
Drawing Template Has Note with Variable :"$PRPSHEET:{Description}".
Note Displays Value : "Assembly1" (Note Has No Name).
Several Other NonNamed Notes Exist Storing Different Variables and there default names change between Several different templates so cannot traverse notes by name to find required note.
Drawing was saved.
Assembly was closed
>:-<
Now With only drawing open dsoFile gives error about file (assem1.sldasm) being open.
If possible I would like to be able to get the value of the variable $PRPSHEET:"Description" Direct from the drawing/model.
Here is a sample of my current code that works but seems long and tediuos:
Public Sub GetCustomInfo_Note(swModelFile As Object)
Dim swModelDoc As Object
Dim varListOfDocs As Variant
Dim docName As String
Dim CustomInfo(9) As String
Dim iCount As Integer
Dim oldDocName As String
'Find First Dependent Document For Drawing
varListOfDocs = swModelFile.GetDependencies(False, True)
docName = varListOfDocs(1)
Set swModelDoc = swApp.ActivateDoc(docName)
'Get Custom Info From Dependant Document
For iCount = 0 To 9
CustomInfo(iCount) = GetCustomInfo(swModelDoc, CLng(iCount))
Next
'Close the Dependant model
swApp.CloseDoc swModelDoc.GetTitle
Set swModelDoc = Nothing
DoEvents
'Populate Drawing with Info From Model
For iCount = 0 To 9
SetCustomInfo swModel, CLng(iCount), CustomInfo(iCount)
Next
'Populate Form From Current Data
Call swApp_ActiveModelDocChangeNotify
End Sub
'--------------------------------------------------
Public Function GetCustomInfo(swModelFile As Object, SumInfoField As swCustomInfoField_e) As String
On Error GoTo ErrHandler
Dim strCustomInfo As String
GetCustomInfo = vbNullString
If swModelFile Is Nothing Then
GetCustomInfo = swDocError
Exit Function
End If
strCustomInfo = swModelFile.CustomInfo(GetCustomInfoName(SumInfoField))
GetCustomInfo = UCase(strCustomInfo)
errHandlerExit:
Exit Function
ErrHandler:
GetCustomInfo = vbNullString
Resume errHandlerExit
End Function
'---------------------------------------------------------
Public Sub SetCustomInfo(swModelFile As Object, SumInfoField As swCustomInfoField_e, Optional InfoValue As String = vbNullString)
Dim strCustomInfo As String
strCustomInfo = UCase(InfoValue)
swModelFile.CustomInfo(GetCustomInfoName(SumInfoField)) = strCustomInfo
End Sub
I am trying to use the dsofile.dll from Microsoft to read the custom properties from a file that is referenced by a drawing. But it says it cannot get the info as the file is open?.
ie. I have a drawing (drw) open in solidworks and my app can see the drawing and its custom props using custominfo but when I get the dependant document path for the assembly (asm) and try to receive the custominfo using dsofile it says the file is already open/in use. But as far as i can see in SWX only the drawing is open?
Anybody got any other ideas on getting the custom properties from the referenced assembly(non configuration specific).
:
eg.
Drawing = assem1.slddrw
Assembly = assem1.sldasm
Drawing was created from Assembly using drag drop in SWX.
Drawing Template Has Note with Variable :"$PRPSHEET:{Description}".
Note Displays Value : "Assembly1" (Note Has No Name).
Several Other NonNamed Notes Exist Storing Different Variables and there default names change between Several different templates so cannot traverse notes by name to find required note.
Drawing was saved.
Assembly was closed
>:-<
Now With only drawing open dsoFile gives error about file (assem1.sldasm) being open.
If possible I would like to be able to get the value of the variable $PRPSHEET:"Description" Direct from the drawing/model.
Here is a sample of my current code that works but seems long and tediuos:
Public Sub GetCustomInfo_Note(swModelFile As Object)
Dim swModelDoc As Object
Dim varListOfDocs As Variant
Dim docName As String
Dim CustomInfo(9) As String
Dim iCount As Integer
Dim oldDocName As String
'Find First Dependent Document For Drawing
varListOfDocs = swModelFile.GetDependencies(False, True)
docName = varListOfDocs(1)
Set swModelDoc = swApp.ActivateDoc(docName)
'Get Custom Info From Dependant Document
For iCount = 0 To 9
CustomInfo(iCount) = GetCustomInfo(swModelDoc, CLng(iCount))
Next
'Close the Dependant model
swApp.CloseDoc swModelDoc.GetTitle
Set swModelDoc = Nothing
DoEvents
'Populate Drawing with Info From Model
For iCount = 0 To 9
SetCustomInfo swModel, CLng(iCount), CustomInfo(iCount)
Next
'Populate Form From Current Data
Call swApp_ActiveModelDocChangeNotify
End Sub
'--------------------------------------------------
Public Function GetCustomInfo(swModelFile As Object, SumInfoField As swCustomInfoField_e) As String
On Error GoTo ErrHandler
Dim strCustomInfo As String
GetCustomInfo = vbNullString
If swModelFile Is Nothing Then
GetCustomInfo = swDocError
Exit Function
End If
strCustomInfo = swModelFile.CustomInfo(GetCustomInfoName(SumInfoField))
GetCustomInfo = UCase(strCustomInfo)
errHandlerExit:
Exit Function
ErrHandler:
GetCustomInfo = vbNullString
Resume errHandlerExit
End Function
'---------------------------------------------------------
Public Sub SetCustomInfo(swModelFile As Object, SumInfoField As swCustomInfoField_e, Optional InfoValue As String = vbNullString)
Dim strCustomInfo As String
strCustomInfo = UCase(InfoValue)
swModelFile.CustomInfo(GetCustomInfoName(SumInfoField)) = strCustomInfo
End Sub