How Export multiple Selected Sheets in single PDF using C# Add in

How Export multiple Selected Sheets in single PDF using C# Add in

Anonymous
Not applicable
854 Views
3 Replies
Message 1 of 4

How Export multiple Selected Sheets in single PDF using C# Add in

Anonymous
Not applicable

How can export multiple selected Sheets of inventor into single pdf in c# add ins ?

Now I can only export single current sheet in PDF.

0 Likes
Accepted solutions (1)
855 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor
Accepted solution

You can use the option "exclude from print" and "exclude from count" in the sheet settings for those you don't want to export....
Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Dimension Component! | Partlist Export! | Derive I-properties! | Vault Prompts Via API! | Vault Handbook/Manual!
Drawing Toggle Sheets! | Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 3 of 4

Anonymous
Not applicable

I have created code which export all shet in single pdf.

How can i use ExcludeFromPrinting and ExcludeFromCount in my following code?Please suggest any option for that?

 

   public void SavePDF_AllSheet(Inventor.Application m_inventorApplication)
        {
            Inventor.TranslatorAddIn PDFAddin = m_inventorApplication.ApplicationAddIns.ItemById["{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}"] as Inventor.TranslatorAddIn;
            DrawingDocument oDocument = (DrawingDocument)m_inventorApplication.ActiveDocument;
            Inventor.TranslationContext oContext = m_inventorApplication.TransientObjects.CreateTranslationContext();
            oContext.Type = Inventor.IOMechanismEnum.kFileBrowseIOMechanism;
            Inventor.NameValueMap oOptions = m_inventorApplication.TransientObjects.CreateNameValueMap();
            // Create a DataMedium object
            Inventor.DataMedium oDataMedium = m_inventorApplication.TransientObjects.CreateDataMedium();
            PropertySet customPropset;
            customPropset = oDocument.PropertySets["Inventor User Defined Properties"];

            Inventor.Property propProjectNumber = null;
            Inventor.Property propCostID = null;
            string inputjobnum = string.Empty, inputcostcode = string.Empty;
            Regex RgxUrl = new Regex("^[a-zA-Z0-9]*$");

            try
            {
                propProjectNumber = customPropset["Project Number"];
                inputjobnum = Convert.ToString(propProjectNumber.Value);

            }
            catch (Exception)
            {

            }

            try
            {
                propCostID = customPropset["Cost Code"];
                inputcostcode = Convert.ToString(propCostID.Value);
            }
            catch (Exception)
            {

            }

            


            if (propProjectNumber == null || propCostID == null)
            {
             
                MessageBox.Show("Job number and/or Cost code is not present in custom properties.", "No Data");
              
                return;
            }

            int sheetCount = oDocument.Sheets.Count;
           
            // Check whether the translator has 'SaveCopyAs' options
            if (PDFAddin.HasSaveCopyAsOptions[oDocument, oContext, oOptions])
            {
                // Options for drawings...
                oOptions.Value["All_Color_AS_Black"] = 1;
                oOptions.Value["Remove_Line_Weights"] = 1;
                oOptions.Value["Vector_Resolution"] = 400;
                // oOptions.Value["Sheet_Range"] = Inventor.PrintRangeEnum.kPrintSheetRange;
                oOptions.Value["Sheet_Range"] = PrintRangeEnum.kPrintAllSheets;
                oOptions.Value["Custom_Begin_Sheet"] = 1;
                oOptions.Value["Custom_End_Sheet"] = sheetCount;
            }
            string filename = oDocument.DisplayName;
           

            string FilePathOriginalPDF = "G:\\PROJECTS\\" + Convert.ToString(inputjobnum) + "\\(03) Design\\(06) PDF\\";
            string FilePathDublicatePDF = "G:\\PROJECTS\\" + Convert.ToString(inputjobnum) + "\\(00) ShopDocs\\" + Convert.ToString(inputcostcode);

            Directory.CreateDirectory(FilePathOriginalPDF);
            Directory.CreateDirectory(FilePathDublicatePDF);
            // Set the destination file name
            oDataMedium.FileName = FilePathOriginalPDF + Convert.ToString(inputcostcode) + "-" + filename + ".pdf";

            // Publish document.
            PDFAddin.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium);

            System.IO.File.Copy(oDataMedium.FileName, FilePathDublicatePDF + "\\" + Convert.ToString(inputcostcode) + ".pdf", true);
          
            MessageBox.Show("PDF saved successfully.", "PDF");
        }

0 Likes
Message 4 of 4

bradeneuropeArthur
Mentor
Mentor

Hi,

 

For example:

Public Sub x()Dim a As Application
Set a = ThisApplication
Dim b As DrawingDocument
Set b = a.ActiveDocument
b.Sheets.Item(1).ExcludeFromCount = True
b.Sheets.Item(1).ExcludeFromPrinting = True
End Sub

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes