Tuesday, October 7, 2014

Cust 37: Export Sheets to PDF: Part 4

...continued from Part 3

Declare two more variables one each to store the Drawing document name and the PDF file name:

Dim sPDFName As String = String.Empty
Dim sDrawingName As String = oDoc.FullDocumentName

The Drawing document's FullDocumentName property returns the path and the name with the .IDW extension which is then stored in sDrawingName.

To Extract the Path of the Drawing use the function:

Dim sPath As String = IO.Path.GetDirectoryName(sDrawingName)

Then build the full name with path for the PDF file as below:

sPDFName = sPath + "\" + System.IO.Path.GetFileNameWithoutExtension(sDrawingName) + ".pdf" ' or dxf, png, swf, dwg

You can even use the message box function the old style way to check if the PDF filename is build correctly:

MessageBox.Show(sDrawingName + vbCrLf + sPDFName)

The final step is to simply call the SaveAs function of the Drawing object to save the drawing in PDF format:

oDoc.SaveAs(sPDFName, True)

The beauty of the SaveAs function is it uses just the changed file extension to save the current document in any of the supported formats automatically.

To see the various formats apart from PDF that can be exported to, select Save As > Save Copy As...

11

In the Save Copy As... dialog observe the Save As type list and note the extensions in bracket.

12

You can use any of these extension in place of PDF in the oDoc.SaveAs argument.

Pick PDF and click the Options button. This brings up the PDF Drawing dialog where you can set the number of sheets to export to PDF. The last used manual setting is used by the API.

01

With the All Sheets option selected, the PDF will contain as many pages as the number of sheets in the drawing.

02

Try changing various extensions in the code and also check the corresponding options dialogs and the various settings for each file type. Note how the last used settings influence the outcome of the exported format from the program.


Full Index of Inventor Tutorials, Tips & Crosswords


Monday, October 6, 2014

Cust 36: Export Sheets to PDF: Part 3

...continued from Part 2

With the button still selected on the Form, change its Image property and browse to an image file that you can easily make in MS Paint or by using capturing small areas of the screen using this utility called LightScreen.

Using an image with a white background, the button would appear as below:

09

To make the image's background transparent, a free program called paint.Net can be used.

Once installed, click the Colors icon in the top-right corner of paint.Net or press F8 to display the Colors palette if not already visible.

05

On the Colors palette, click the More>> button

06

07

On the expanded palette, Right-Click on the color in the bottom left corner which looks like chequered gray and white. This is a transparent color or Alpha Channel. By right-clicking this becomes the secondary or background color.

Next, select the 'Magic Wand' tool from the Tools palette and click in the white area of the image. Press Delete on the keyboard. The color is now replaced with the secondary color i.e. transparent color represented by a gray + white tiled pattern.

08

When assigned to the Image property of the PictureBox control, the image appears as below.

04

The button's background color fills the transparent color on the image which then renders seamlessly on the button.

Double-Click the button to enter its Click event.

Just above the Click event but under the Form1 class, add the variables for Inventor and the drawing document:

Public Class Form1
    Dim oApp As Inventor.Application
    Dim oDoc As Inventor.DrawingDocument

   Private Sub btnExportSheets_Click(sender As System.Object, e As System.EventArgs) Handles btnExportSheets.Click

For the Click event of the button, first store the current instance of Inventor in the oApp variable using the GetActiveObject method of the Marshal class. The Marshal class was made available by importing the Runtime.InteropServices namespace of .Net at the top of the code window.

Similarly, oDoc stores the Inventor Drawing Document that you want to export to one of the formats PDF, DXF, etc.

Continued to part 4...


Full Index of Inventor Tutorials, Tips & Crosswords


Sunday, October 5, 2014

Cust 35: Export Sheets to PDF: Part 2

...continued from part 1

This tutorial uses Visual Studio 2010 .Net 4.0 and Inventor 2015

Start Visual Studio and create a New Project.

Select Visual Basic from the Installed Templates and then Windows Forms Application.

05

In the Name Textbox enter ExportSheets and specify a Location for the Project using the Browse button.

Keep the Create and Add check boxes un-checked. Click OK.

06

From the Project menu, select Add Reference and from the COM tab select Autodesk Inventor Object Library.

07

At the top of the code window, add the following lines:

Imports Inventor
Imports System.Runtime.InteropServices
Imports System.IO

The first statement enables to use Inventor objects.

The System.Runtime.InteropServices has a Marshal class that helps to connect to Inventor as you will see soon.

The System.IO statement has file handling functions that help in exporting the Inventor drawings to various formats like PDF, DXF, etc.

From the menu select View > Toolbox and from the Toolbox add a Button 08 to the Form as below:

04

Select the button and change the Font size to 12 from the Properties window which if not visible can be made to be so from the menu View > Properties Window.

Few useful tips on adding a transparent image to the button and subsequent coding follows in Part 3...


Full Index of Inventor Tutorials, Tips & Crosswords


Saturday, October 4, 2014

Cust 34: Export Sheets to PDF: Part 1

In this tutorial you learn, using VB.Net:

  1. How to export one or all sheets in an Inventor drawing to PDF format.
  2. How to derive a file name for the PDF from the drawing document.
  3. How to control which sheets are exported to PDF.
  4. How to make transparent images for placing on buttons.

The user interface sports a single button for ONE-CLICK operation:

04

This Inventor programing tutorial uses Visual Studio 2010, .Net 4.0 and Inventor 2015

Continued to part 2...


Full Index of Inventor Tutorials, Tips & Crosswords


Thursday, October 2, 2014

Tuesday, July 8, 2014

Inventor Surfacing Triangular and Star Springs

This tutorial shows how to make a springs of non-circular section like Triangular, Star, Square, etc. using the Intersection Curve tool.

 

Spring_Triangle_320.ipt           Spring_Star_320

A similar tutorial that shows how to model an Hourglass spring is here.

Index of all Inventor tutorials is here.

Monday, February 10, 2014

Wednesday, February 5, 2014

The Ten Commandments of Solid Modeling with Inventor Part2

This is Part 2 of the 10 rules that can save hours of work each day by saving drafting (layout) time, ensuring adherence to company standards, and allowing changes to be easily absorbed, with little effort on the your part.

Full index of All Inventor Tutorials, Articles, Tip, Tricks & Surprises is Here

The Ten Commandments of Solid Modeling with Inventor Part1

Welcome to the world of parametric modeling with Inventor !

The old days of creating static 2-D drawings of your designs is over. Along with advanced functionality, there are a few more considerations to be made when creating geometry than just layering schemes and line fonts.

In order to create a flexible and reusable solid model, there are certain standard methodologies that should be used. The following list of rules will help the novice user and 3D expert alike, generate robust and solid models.

These 10 rules can save hours of work each day by saving drafting (layout) time, ensuring adherence to company standards, and allowing changes to be easily absorbed, with little effort on the your part.

Full index of All Inventor Tutorials, Articles, Tip, Tricks & Surprises is Here

Friday, January 24, 2014

Cust 33: Inventor Sheets: C++/MFC

In this tutorial you learn using C++ with MFC how to:

• Create new drawing sheets.
• Count the number of sheets in a drawing.
• Determine common sheet properties like size, type
• Activate a sheet by its name.
• Remove or delete a sheet from a drawing.

VB.Net version of this tutorial is here.
CSharp version is here.
C++/CLI i.e. managed C++ version is here.

A list of all Inventor tutorials on this blog is here.

image

Cust 32: Inventor Sheets: C++/CLI

In this tutorial you learn using C++/CLI i.e. managed C++ how to:

• Create new drawing sheets.
• Count the number of sheets in a drawing.
• Determine common sheet properties like size, type
• Activate a sheet by its name.
• Remove or delete a sheet from a drawing.

VB.Net version of this tutorial is here.
CSharp version is here.
C++ with MFC version is here.

A list of all Inventor tutorials on this blog is here.

image_thumb

Thursday, January 23, 2014

Cust 31: Inventor Sheets: VB.Net

In this tutorial you learn using VB.Net how to:

• Create new drawing sheets.
• Count the number of sheets in a drawing.
• Determine common sheet properties like size, type
• Activate a sheet by its name.
• Remove or delete a sheet from a drawing.

CSharp version of this tutorial is here.
C++/CLI i.e. managed C++ version is here.
C++ with MFC version is here.

A list of all Inventor tutorials on this blog is here.

image_thumb

Cust 30: Inventor Sheets: CSharp

In this tutorial you learn using CSharp how to:

• Create new drawing sheets.
• Count the number of sheets in a drawing.
• Determine common sheet properties like size, type
• Activate a sheet by its name.
• Remove or delete a sheet from a drawing.

VB.Net version of this tutorial is here.
C++/CLI i.e. managed C++ version is here.
C++ with MFC version is here.

A list of all Inventor tutorials on this blog is here.

image

Surface Modeling Pep Backrest

This tutorial shows how to make a Pep Backrest using the Intersection Curve tool.

A similar tutorial that shows how to model a boxer backrest is here.

Index of all Inventor tutorials is here.

Image_Small

Index of all tutorials on this Inventor blog: i Surf and Code

Inventor Surfacing Tutorials

Intro  |  Squeeze Bottle  |  Baby Bottle  |  Mouse  |  Helmet Windshield  |  Mountain Bike Handlebar  |  Door Handle  |  Fountain Pen Nib  |  Hourglass Spring  |  Boxer Backrest  |  Toroidal Spring  |  Automobile Bonnet  |  Tennis Ball  |  Gold Ring with Diamond  |  Pep Backrest  |  Hair Dryer  |  Triangular and Star Spring  | 

Programming (Inventor Customization) Tutorials

  1. Start-Show-Stop: CSharp  |  VB.Net  |  C++/CLI  |  C++/MFC

  2. Determine Inventor Document Types: CSharp  |  VB.Net  |  C++/CLI  |  C++/MFC

  3. Inventor File Handling, New, Open, Save, Export, etc.: CSharp  |  VB.Net  |  C++/CLI  |  C++/MFC

  4. Inventor File Dialogs: CSharp  |  VB.Net  |  C++/CLI  |  C++/MFC

  5. Inventor Drawing Sheets: CSharp  |  VB.Net  |  C++/CLI  |  C++/MFC

  6. Export Drawings to PDF, DXF, etc.

Inventor Crosswords

Crossword #001  |  Crossword #002  |  Crossword #003 Crossword #004 

Inventor Tips

Tip 001  |  002  |  003  |

Inventor Articles

The Ten Commandments of Solid Modeling  |