VBA Return project template path

VBA Return project template path

pball
Mentor Mentor
2,319 Views
5 Replies
Message 1 of 6

VBA Return project template path

pball
Mentor
Mentor

Is there a way with the api to return the path of the template folder for the active project. I currently have a hard coded location for templates but we are changing some standards and new projects will use a different template folder. So I'd like to be able to return the path set in the project file, wether it's set as default or a project specific location. Thanks

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Accepted solutions (1)
2,320 Views
5 Replies
Replies (5)
Message 2 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi pball,

 

Good thinking, I should start doing this as well.

 

    Dim sPath As String
    sPath = ThisApplication.DesignProjectManager.ActiveDesignProject.TemplatesPath
    MsgBox (sPath)

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

EESignature

Message 3 of 6

pball
Mentor
Mentor

Thanks Curtis, that is exactly what I'm looking for. Didn't know about the design project manager property before but it could come in handy again I bet.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 4 of 6

Anonymous
Not applicable

Curtis,

 

I have the code stated below, I was hoping you could help with a few things:

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 24470 StartFragment: 314 EndFragment: 24438 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Sub Main
    iLogicVb.RunRule("CustOn")



'query user
MessageBox.Show("Would you like to print to the current Project File?: ", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
'set condition based on answer
If question = vbYes Then
    oFileName = ThisDoc.FileName(False) 'without extension
    oRevNum = iProperties.Value("Project", "Revision Number")
    
    Else
    
    End If
    

    
    ' Get the PDF translator Add-In.
    Dim PDFAddIn As TranslatorAddIn
    PDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
                            ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

    'Set a reference to the active document (the document to be published).
    Dim oDocument As Document
    oDocument = ThisApplication.ActiveDocument
     Dim oContext As TranslationContext
    oContext =  ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = kFileBrowseIOMechanism
    'Create a NameValueMap object
    Dim oOptions As NameValueMap 
     oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    ' Create a DataMedium object
    Dim oDataMedium As DataMedium
    oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
    ' Check whether the translator has 'SaveCopyAs' options
    If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
        
        ' Options for drawings...
        'oOptions.Value("Launch_Viewer") = launchviewer
        oOptions.Value("All_Color_AS_Black") = 1
        'oOptions.Value("Sheet_Range") = ThisApplication.PrintRangeEnum.kPrintAllSheets
        oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets

        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400
        
        'oOptions.Value("Custom_Begin_Sheet") = 2
        'oOptions.Value("Custom_End_Sheet") = 4
    End If
    'get PDF target folder path
    oFolder = Left(ThisDoc.Path, InStrRev(oPath, "\")) & "PDF"
    'Check for the PDF folder and create it if it does not exist
        If Not System.IO.Directory.Exists(oFolder) Then
            System.IO.Directory.CreateDirectory(oFolder)
        End If
        
     'Set the PDF target file name
    Dim fname As String
    fname = oFolder & "\" & oFileName & " Rev" & oRevNum & "-CUST.pdf" 
    oDataMedium.FileName = fname
    'Publish document.
    If  System.IO.Directory.Exists(fname) Then
        System.IO.File.Delete(fname)
        MessageBox.Show("Earlier PDF deleted! ", "Inventor")
    End If
    PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
    MessageBox.Show("Print Created in default Projects -  "  & fname, "Inventor")

End Sub



First I was hoping I could have the project name added after the question in the project file. Also I was going to try and set up a browser the would pop up if you were to hit no where you can manually map the file where you'd like it to save?

 

Any ideas? I am pretty new to all of this and its getting a little too complex for my experience.

0 Likes
Message 5 of 6

pball
Mentor
Mentor
You should really post this question in a new post.
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 6 of 6

Anonymous
Not applicable

I did. But do you by chance have any ideas?? The problem solved here is similar partially to the problem I am having.

0 Likes