×
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

API - ReferenceNotFoundNotify

API - ReferenceNotFoundNotify

API - ReferenceNotFoundNotify

(OP)
in the following example the FileOpenNotify works perfectly but the ReferencenotFoundNotify doesn't seem to work.

Does Anyone have a idea y??

CODE

Public WithEvents swApp As SldWorks.SldWorks

Sub init()
  Set swApp = CreateObject("SldWorks.Application")
  swApp.Visible = True
End Sub

Private Sub Form_Load()
  init
End Sub

Private Function swApp_FileOpenNotify2(ByVal Filename As String) As Long
  MsgBox "File Open Notify"
End Function

Private Function swApp_ReferenceNotFoundNotify(ByVal Filename As String) As Long
  MsgBox "Reference Not Found"
End Function

Regards,

Bouke

RE: API - ReferenceNotFoundNotify

I'm assuming the reference was not found.

What kind of reference was missing when you tested this?  Missing component?  Missing in-context ref?

One possibility is that your options are not set to load referenced documents.  SW is not going to fail to find something its not looking for.

I could be the world's greatest underachiever, if I could just learn to apply myself.
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: API - ReferenceNotFoundNotify

(OP)
Ok, I will give some more information of the problem. I just got off the phone with my VAR and he couldn't help me so.

I want the macro to trigger when I open a drawings wich has lost its reference to the part/assembly (for example by renaming it) When you open such a drawing normally you get the "File not found, would you like to find it yourself"-dialog box.

Now when I let my macro listen for this event Solidworks wont respond. It doesn't pop up the dialog either. Instead it changes the drawings-views to empty crosses.

But when I open anything It will respond with the fileopen-event.


Me and my Var were able to get it working using VBA, but I really need this in VB6.0

Regards, Bouke

RE: API - ReferenceNotFoundNotify

Bouke,
I wanted to do this also, but could not figure it out. What I did was put my code into code that most people already use every time they work on a drawing, assembly or part. If you figure this trigger out could you please post it? I would love to incorporate the trigger into my programs.

Bradley

RE: API - ReferenceNotFoundNotify

I did some quick testing and it looks like (at least with the default installation settings), if SW cannot find the referenced file, it sets it to unresolved instead of triggering the notify flag.  Then, when you set it to resolved, the flag is triggered.

Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...

RE: API - ReferenceNotFoundNotify

I just tested using my own event monitor program.  I opened a part drawing with the part file missing.  The ReferenceNotFoundNotify triggered fine.

One thing I noticed about events:
If you have too much code responding to a single event, your program can miss other events.  It's possible that your MsgBox is drowning out subsequent event calls.

One way around this is to start your code asynchronously.  If your code is in a form, you can use a timer.  Have the event enable a timer, then have the timer run some code after a minimal wait and then disable itself.

I could be the world's greatest underachiever, if I could just learn to apply myself.
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: API - ReferenceNotFoundNotify

(OP)
The tick, The code you see above was all the code I used. I tried to change the msgbox's to debug.print but that doesn't change anything. Yesterday I did some more testing and I did sent the VB-project to Solidworks Api Support. Seems they've got it working and my VAR to. There was just 1 little differnence between them and me. They worked with SW2005-SP0.0 and I work with 0.1 so I'm guessing maybe the problem lies in the Service pack. I'm hoping it will be fixed in SP1.0

Bouke Brouwers
Mechanical Engineer
SW2005 SP0.1

RE: API - ReferenceNotFoundNotify

Interesting - as of about 15 min prior to my post, I was using SP0.0, too.  BUT, when I did my testing, I was now running SP0.1.  

Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...

RE: API - ReferenceNotFoundNotify

(OP)
Then we just have to wait till service pack 1.0 Maybe there is someone with the early visibility Service pack who can test it??

Regards,

Bouke Brouwers
Mechanical Engineer
SW2005 SP0.1

RE: API - ReferenceNotFoundNotify

OK - something else appears to be going on here.  When I run the code against 0.1 and 0.0 with a drawing, it triggers properly (the reference not found flag is thrown instead of the file open).  However, when it do it against an assy with a missing reference, I cannot get reference not found to go b/c it just makes the component unresolved.

Is this worth researching further?

Evan T. Basalik, MCSD
--------------------------------
It's all about prioritization...

RE: API - ReferenceNotFoundNotify

(OP)
Currently I have made a new install of SW2005 on my pc (I used to have one made with an administrative image) so I was able to put the SP1.0 RC over it.

The notify is working fine now. I even found a SPR, but it wasn't a general one so overlooked it the first time.


Bradley, do you still want to know how to use this??

Regards,

Bouke Brouwers
Mechanical Engineer
SW2005 SP0.1

RE: API - ReferenceNotFoundNotify

Bouke,
Yes, I would like to know how to start a Visual Basic 6 exe program when SolidWorks starts. Currently, what I have to do is start a drawing, then my macro keys will work.

Bradley

RE: API - ReferenceNotFoundNotify

Look up "ShellExecute" Windows API.  This is the API command to kick off a program or open a file in its default app.

I could be the world's greatest underachiever, if I could just learn to apply myself.
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: API - ReferenceNotFoundNotify

This is the code that I tried to make a program start when starting a drawing.

CODE

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
' This program runs when I pushed Ctrl F12

MyAppID = Shell("\\ServerName\Eng\Applications\SolidWorks\Executables\Titleblock.exe", 1)

Bradley

RE: API - ReferenceNotFoundNotify

(OP)
Bradley,

it sounds to me that you want the Titleblock.exe program to run automatically when you start SW.

You could add the following function to your program. Then put it into your init() or main()

Now when you start titleblock.exe it will look for Solidworks 2005. If its not there it will aumatically start SW2005.

So this way you dont need your SW-icon anymore

CODE

Private Function StartSolidWorksAndConnect()
On Error Resume Next
    ' start solidworks
    Set swApp = Nothing
    Set swApp = GetObject(, "SldWorks.Application.13")
    If swApp Is Nothing Then Set swApp = CreateObject("SldWorks.Application.13")
    If Not swApp Is Nothing Then
        swApp.Visible = True
        swApp.UserControl = True
        bReady = True
    End If
End Function

btw, If you work in 2004 you need to change the application number from 13 to 11. I think, I'm not sure on that one though. If its not working, experiment with other numbers below 13

Bouke Brouwers
Mechanical Engineer
SW2005 SP1.0

RE: API - ReferenceNotFoundNotify

Thanks Bouke,
    I will give this a try soon. I do use SolidWorks 2005. This will help a lot in setting the revision on our drawings to our standard. I read our “revision-version” in the format R01-01 and use VB to change it to R01 in our title block.
Thanks again

Bradley

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