Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

perform Explorer "Open With..." on part file inside inventor

Chris.Brough
Enthusiast

perform Explorer "Open With..." on part file inside inventor

Chris.Brough
Enthusiast
Enthusiast

I am looking for a way to perform a script or macro inside of inventor that would do the following:

  1. select part or component to perform a similar operation to Explorer's "open with" command and tell it to open specifically in our CAM application "AlphaCAM.exe".
    • best thought on this is to start with an "open file location" ilogic rule of which i've seen many posts for this. can this be followed by VBA that acts on the selected file in explorer to invoke the "open with" command?
  2. Either add a parameter or custom iproperty field would be created to flag the file with an export date and Boolean
    • this would operate as a check list to keep track of each component that has been exported for CAM

Thanks in advance for your input!

0 Likes
Reply
508 Views
3 Replies
Replies (3)

Chris.Brough
Enthusiast
Enthusiast

i think i'm getting close... here's my code:

 

Dim Proc As String = "C:\Program Files\Hexagon\ALPHACAM 2020.1\Acam.exe "
Dim Path As String = Chr(34) & ThisDoc.PathAndFileName(True) & Chr(34)

Process.Start(Proc & Path)

 

I'm able to start the application if i just use Process.Start(Proc) but as soon as i add the path, i get an error:

 

Error in rule: OpenPartAlphacam, in document: RightStileFD_Substitute_1.ipt

The system cannot find the file specified

 

When i run this in CMD it works fine.  Is there any  security blockage that would keep inventor from accessing the filepath through the "process" function?

 

any other thoughts?

0 Likes

JelteDeJong
Mentor
Mentor

try this:

Dim p As New ProcessStartInfo
p.FileName = "C:\Program Files\Hexagon\ALPHACAM 2020.1\Acam.exe"
p.Arguments = ThisDoc.PathAndFileName(True)
Process.Start(p)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes

k14348
Advocate
Advocate

Hi,

    Dim oApp As Inventor.Application
    Set oApp = ThisApplication
    
    Dim oDPmgr As DesignProjectManager
    Set oDPmgr = oApp.DesignProjectManager
    
    Dim oDP As DesignProject
    Set oDP = oDPmgr.ActiveDesignProject
    
    Dim oWpath As String
    oWpath = oDP.WorkspacePath
    
    Dim oDrawingDoc As Document
    
    Dim FB As Inventor.FileDialog
    Call ThisApplication.CreateFileDialog(FB)
       
    FB.DialogTitle = "Select Ref Drawing"
    If oWpath <> vbNullString Then

    FB.InitialDirectory = oWpath
    
    End If
    
    FB.Filter = "*.idw;|*.idw;"
    FB.ShowOpen
    If FB.FileName = vbNullString Then Exit Sub
    
    Dim oNVM As NameValueMap
    Set oNVM = ThisApplication.TransientObjects.CreateNameValueMap
    Call oNVM.Add("DeferUpdates", True)
    
    oApp.SilentOperation = True
    
    Dim oDoc As Document
    Set oDoc = oApp.Documents.OpenWithOptions(FB.FileName, oNVM)

 

Hope you are expecting something similar to this. 

 

-Karth

0 Likes