×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

DSOFile Not Working! Need Custom Props!

DSOFile Not Working! Need Custom Props!

DSOFile Not Working! Need Custom Props!

(OP)
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

RE: DSOFile Not Working! Need Custom Props!

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 :"$PRPSHEET:{Description}".

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

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

Don't give up...

Mr. Pickles

RE: DSOFile Not Working! Need Custom Props!

(OP)
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 " 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

RE: DSOFile Not Working! Need Custom Props!

Check this Thread559-13712, Ithink you'll find your answer there.

Andrew

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources