473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Insert 1 Document Into Another Document - A part into an assembly drawing

I know this code references Autodesk Inventor (CAD) API, but I'm hoping for a generic solution to my problem with the following error. The error is "object reference not set to an instance of an object" and the macro takes an open document (part file drawing) and inserts it into another open document (assembly file).

Code:
Expand|Select|Wrap|Line Numbers
  1.         ' Set a reference to the assembly component definintion.
  2.         ' This assumes an assembly document is open.
  3.         Dim oAsmCompDef As AssemblyComponentDefinition
  4.         oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
  5.  
  6.         ' Set a reference to the transient geometry object.
  7.         Dim oTG As TransientGeometry
  8.         oTG = ThisApplication.TransientGeometry
  9.  
  10.         ' Create a matrix. A new matrix is initialized with an identity matrix.
  11.         Dim oMatrix As Matrix
  12.         oMatrix = oTG.CreateMatrix
  13.  
  14.         ' Add the occurrence.
  15.         Dim oOcc As ComponentOccurrence
  16.         oOcc = oAsmCompDef.Occurrences.Add(sFileName, oMatrix)  
Hopefully this is not too specialized to receive help in this forum.

Thx,
Jon
Nov 12 '08 #1
1 1412
Ok, let me simplify my explanation of what's going on. I get "Object variable or With block variable not set" when trying to execute the following that refers to the active document. I’ve also gotten the error, which is related, “object reference not set to an instance of an object.”

Dim oAsmCompDef As Inventor.AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Any idea why this would be happening?

Jon
Nov 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
5
by: Greg Collins [MVP] | last post by:
I have an ASP.NET page that uses a tag: <asp:Xml id="foo" runat="server" DocumentSource="rss.xml" TransformSource="rss20.xsl" /> This creates a Web page from an XML file that was generated by...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
2
by: mirandacascade | last post by:
O/S: Win2K Vsn of Python: 2.4 Example: <a> <b createAnotherWhenCondition="x"> <c>text for c</c> <d>text for d</d> </b>
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
0
by: Ramesh2006 | last post by:
Hi, The following error occurred when i programmatically compile another project from my present project. The Error: error CS0234:The type or namespace name 'Windows' does not exist in the...
2
by: rjjaw | last post by:
Here is what I have but it isn't working if someone could point me in the right direction I would greatly appreciate it. Try Dim objAssembly As Reflection.Assembly...
0
by: yoozioo | last post by:
hello, This year I'm learning C# at school and now we focus on web services. I created and published a web service which contains a method that calls another web service written by my class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.