OnPopulateFileMetadata problem

OnPopulateFileMetadata problem

DWhiteley
Advisor Advisor
826 Views
4 Replies
Message 1 of 5

OnPopulateFileMetadata problem

DWhiteley
Advisor
Advisor

Here's an odd one.

 

With reference to this post - which works fine for me in Inventor 2016 by the way:

 

http://adndevblog.typepad.com/manufacturing/2013/12/when-fileuieventsonpopulatefilemetadata-is-exact...

 

I can't get the filename of a "save as" or "save copy as" operation to change to the newfilename from this routine.

 

 

Private Sub m_fileUIEvts_OnPopulateFileMetadata(ByVal FileMetadataObjects As ObjectsEnumerator, ByVal Formulae As String, ByVal Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum)

 

.......

 

Dim current As Inventor.FileMetadata

 

          'Dim oMetaData As FileMetadata
           'If FileMetadataObjects.Count > 0 Then
           'For Each oMetaData In FileMetadataObjects
           'suggest custom name
            'oMetaData.FileName = "asdk_" & oMetaData.FileName
            'oMetaData.FileNameOverridden = True
             'Next oMetaData
            'tell Inventor the event is handled
           'HandlingCode = HandlingCodeEnum.kEventHandled
            'End If
            'current = DirectCast(FileMetadataObjects.Item(1), FileMetadata)
            'current = FileMetadataObjects.Item(1)
            'current.FileName = str2
            'current.FileNameOverridden = True

System.Windows.Forms.Application.DoEvents()

current = DirectCast(FileMetadataObjects.Item(1), FileMetadata)
current.FileName = str2
current.FileNameOverridden = True
HandlingCode = Inventor.HandlingCodeEnum.kEventHandled

System.Windows.Forms.Application.DoEvents()

             'For Each current In FileMetadataObjects
             'current.FileName = str2
              'current.FileNameOverridden = True

              'Next

             'HandlingCode = HandlingCodeEnum.kEventHandled

 

 

As you can see, i've tried all sorts of ways, but no matter what I di the file always save as part1.ipt etc.

 

Can anyone out there see what the problem might be?

 

Many thanks

 

Dave

0 Likes
827 Views
4 Replies
Replies (4)
Message 2 of 5

DWhiteley
Advisor
Advisor

Just to make things simpler, this may help. i've taken out of my routine the main parts :

 

Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer

 

' Inventor application object.
Private m_inventorApplication As Inventor.Application

Private WithEvents m_AppEvents As Inventor.ApplicationEvents

Private WithEvents m_fileUIEvts As Inventor.FileUIEvents

.

.

.

 

 

Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate

 

m_inventorApplication = addInSiteObject.Application

 

m_AppEvents = m_inventorApplication.ApplicationEvents
m_fileUIEvts = m_inventorApplication.FileUIEvents

AddHandler m_fileUIEvts.OnPopulateFileMetadata, AddressOf m_fileUIEvts_OnPopulateFileMetadata

.

.

.

 

 

 

 

Private Sub m_fileUIEvts_OnPopulateFileMetadata(ByVal FileMetadataObjects As ObjectsEnumerator, ByVal Formulae As String, ByVal Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum)

 

Dim oMetaData As FileMetadata
If FileMetadataObjects.Count > 0 Then
  For Each oMetaData In FileMetadataObjects
    'suggest custom name
    oMetaData.FileName = "asdk_" & oMetaData.FileName
    oMetaData.FileNameOverridden = True
 Next oMetaData
'tell Inventor the event is handled
HandlingCode = HandlingCodeEnum.kEventHandled
End If

.

.

.

 

 

 

Even this fails to override the filename in the save dialog, although it does debuf through ok.

 

Dave

 

0 Likes
Message 3 of 5

rossano_praderi
Collaborator
Collaborator

Look at this sample, it's a good explaination for personalize OnSave event.

http://modthemachine.typepad.com/my_weblog/2013/07/add-in-with-event-example-to-replace-auto-run-mac...

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 4 of 5

DWhiteley
Advisor
Advisor
Thanks for the post Rossano,



It's not quite what I'm trying to do though.



I have had OnPopulateFileMetadata working in the past in order to override
the filename in the file save dialog, but for some strange reason

it's not working in Inventor 2016.



Just to mention, I'm using VS2010 - could this be the problem? Should I move
up to VS2013 for example?





Dave
0 Likes
Message 5 of 5

rossano_praderi
Collaborator
Collaborator

Sorry for my misunderstanding Dave,
I've make a test with the vba code and I haven't fiund any problem.

 

Cattura.JPG

 

I don't think is a problem of VS2010.

 

Can you post sample files and part of your code for make some tests?

If you don't like to publish your files you can send me a private message.

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes