Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

DSOFile Not Working! Need Custom Props! 1

Status
Not open for further replies.

DohPee

Computer
Jun 25, 2002
12
0
0
ZA
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:&quot;Description&quot; Direct from the drawing/model.

Here is a sample of my current code that works but seems long and tediuos:
[pc3]
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
 
Replies continue below

Recommended for you

I'm confused about what you need. Possibly others are too...?

I control SW files with M$ Excel, therefore I HAVE to have DSO installed. If the relevant file is Open, I CAN NOT access the Custom Props, which I assume is your problem?

If you just have the drawing open, you actually have the Assembly and Parts open as well. When you save the drawing, the relevant parts, etc. will also be saved, if they need to be.

If you use M$ Explorer, you can right-click on a part, assembly, or drawing file and choose Properties. You will see a Custom Tab if the file isn't opened. Try it on a file opened, and one not opened. Different Property choices.

So, from that mess, I believe that DSO is working on the operating system level. If the file is opened (actually or through osmosis), DSO can't do anything with it.

Also, you stated the following:
...Note with Variable :&quot;$PRPSHEET:{Description}&quot;.

I don't use brackets around my Property. I would write it like this:
$PRPSHEET:&quot;Description&quot;

Maybe this sheds some light on your deal? Maybe not?

Don't give up... Mr. Pickles
 
You Hit The Nail on the Head...

I want to view the custom properties of the assembly WHILE the drawing is opened. This is where the problem comes in.
as DSO works fine with drawing and assembly closed but not with open. That is why I would like to call the variable direct. BTW. I did use &quot; parenthesis in my variable I only wrote it with brakets so that it would be clearer here..or so I thought.

Now you say that the Assembly is open while the drawing is open.. do you think it would be possible to swap model in the api to get the necessary props??? Ill try and give it a bash. Thanx
 
Status
Not open for further replies.
Back
Top