How do we create part or drawing or assembly programatically?

How do we create part or drawing or assembly programatically?

Anonymous
Not applicable
3,627 Views
9 Replies
Message 1 of 10

How do we create part or drawing or assembly programatically?

Anonymous
Not applicable

Hi Experts,

                 We have a requirement to create standart parts ,drawing and assembly as part of our functionality . Can you please let me know how can we achieve this?

 

note: These part will be created blank with no geometry,sketches and other details.

 

Thanks and Regards

Rajesh

0 Likes
3,628 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Hi ,

 

Using VBA macro in Inventor you can create a new part like this,

 

Sub newDoc()

 

 Dim oPart As PartDocument

Set oPart = ThisApplication.Documents.Add(kPartDocumentObject, "C:\\Users\Public\\Documents\\Autodesk\\Inventor 2011\\Templates\\English\\Standard (in).ipt", True)

 

End Sub

 

Another way using VB.Net console Application.....

 

1.Here im trying to connect a running inventor or starting new inventor application

2.Then creating a new part document.

 

 

Module Module1
Public inventorApp As Inventor.Application
Public inventordoc As Inventor.Document
Public invPDoc As Inventor.PartDocument


Sub Main()

' Enable error handling.
Try
' Try to connect to a running instance of Inventor.
inventorApp = GetObject(, "Inventor.Application")
Catch ex As Exception
Try
' Try to open Inventor.
inventorApp = CreateObject("Inventor.Application")
inventorApp.Visible = True
Catch ex2 As Exception
' Unable to start Inventor.
MsgBox("Unable to connect to or start Inventor.")
Exit Sub
End Try
End Try
Threading.Thread.Sleep(5000)
inventordoc = inventorApp.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject, "C:\\Users\Public\\Documents\\Autodesk\\Inventor 2011\\Templates\\English\\Sheet Metal (in).ipt", True)

End Sub

End Module

 

Same way you can create empty drawing & Assembly file.Hope it helps..

 

 

Message 3 of 10

Anonymous
Not applicable

Hi Expert,

              Thanks for the quick reply. I have couple of questions, can we implement the same using C#? Can we create a blank drawing and associate to part later?

 

@Anonymous for a asking the question: I have to create a part or drawing or assembly. and then check in the vault programattically.

 

Regards

Rajesh

 

0 Likes
Message 4 of 10

Anonymous
Not applicable

In c# also you can do this as below.But i dont know about checking or comparing files in vault.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO ;
using System.Text;
using Inventor;
using System.Runtime.InteropServices;
using System.Diagnostics ;
using System.Threading;


namespace InventorCSharp
{
class Program
{

static void Main(string[] args)
{
Application inventorApp = null;
Document inventordoc = null;

// Enable error handling.
try {
// Try to connect to a running instance of Inventor.
inventorApp = (Application)Marshal.GetActiveObject("Inventor.Application");
}
catch (Exception ex)
{
// Connecting to a running instance failed so try to start Inventor.
try {

inventorApp = (Application)Activator.CreateInstance (Type.GetTypeFromProgID("Inventor.Application"),true );

inventorApp.Visible = true;
}
catch (Exception ex2)
{
// Unable to start Inventor.
Console.WriteLine ("Unable to connect to or start Inventor.");
return;
}
}
System.Threading.Thread.Sleep(5000);
inventordoc = inventorApp.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject, "C:\\Users\\Public\\Documents\\Autodesk\\Inventor 2011\\Templates\\English\\Sheet Metal (in).ipt", true);

 


}
}
}

 

 

Message 5 of 10

Anonymous
Not applicable

Work great, thanks for the code and explanation.Since am very new to this it helps me lot to understand.Great work and thanks once again.

0 Likes
Message 6 of 10

Anonymous
Not applicable

Hai, Since am very new to Autodesk i need a help. I want create a drawing in autodesk inventor though VB. So for i have open the auotdesk application using VB.net code. If any one have idea to create new drawing code using VB .Net in autodesk please let me know. Thanks 

0 Likes
Message 7 of 10

dgreatice
Collaborator
Collaborator

Hi all,

 

 

Already search from this forum using search engine with subject "Create Drawing"?

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 8 of 10

tonythm
Advocate
Advocate

Hi,

 

You can try this:

Sub newDoc()

Dim oPart As PartDocument
Dim oAssembly As AssemblyDocument
Dim oDrawing As DrawingDocument

Set oPart = ThisApplication.Documents.Add(kPartDocumentObject, "C:\\Users\Public\\Documents\\Autodesk\\Inventor 2019\\Templates\\TMStandard.ipt", True)
Set oAssembly = ThisApplication.Documents.Add(kAssemblyDocumentObject, "C:\\Users\Public\\Documents\\Autodesk\\Inventor 2019\\Templates\\TMStandard.iam", True)
Set oDrawing = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\\Users\Public\\Documents\\Autodesk\\Inventor 2019\\Templates\\TMStandard.dwg", True)

End Sub

0 Likes
Message 9 of 10

Anonymous
Not applicable

please explain the difference

0 Likes
Message 10 of 10

JelteDeJong
Mentor
Mentor

did you see this blog post?

https://adndevblog.typepad.com/manufacturing/2012/06/creating-a-drawing-from-scratch-with-the-invent... 

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