add method error

add method error

Anonymous
Not applicable
590 Views
6 Replies
Message 1 of 7

add method error

Anonymous
Not applicable
hello
i have a problem in Inventor 10 with the add method, which i didn't have in inventor 8, it's very puzzling. I open an assembly, add some parts (this goes without problems) then i open another assembly, change some stuff,close it again, so i'm back in the first assy and then the next add method fails.

please help me out. thanks
Anton Sterenborg M Eng

here's a view of what i want basically:
Public Sub AddOccurrence()
' open assy
Set oAssy = ThisApplication.Documents.Open("C:\Temp\Assy.iam", True)

' Set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

Set oMatrix = Inventor.GetApp.TransientGeometry.CreateMatrix

' Add the occurrence.
Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences.Add("C:\Temp\Part1.ipt", oMatrix)

' open a subassy
Set oSubAssy = ThisApplication.Documents.Open("C:\Temp\SubAssy.iam", True)
oSubAssy.close

Set oMatrix = Inventor.GetApp.TransientGeometry.CreateMatrix

' Add the subassy to assy.iam
Dim oOcc1 As ComponentOccurrence
Set oOcc1 = oAsmCompDef.Occurrences.Add("C:\Temp\ SubAssy.iam ", oMatrix)

End Sub
0 Likes
591 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Anton,

I wasn't able to reproduce the problem. The one thing to check in your code
would be the document name string in the last line of your code. There seem
to be spaces before and after "SubAssy.iam". You'll need to get rid of
those. Also in the following line:

Set oMatrix = Inventor.GetApp.TransientGeometry.CreateMatrix

Did you mean to write:

Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix

Sanjay-


wrote in message news:5229849@discussion.autodesk.com...
hello
i have a problem in Inventor 10 with the add method, which i didn't have in
inventor 8, it's very puzzling. I open an assembly, add some parts (this
goes without problems) then i open another assembly, change some stuff,close
it again, so i'm back in the first assy and then the next add method fails.

please help me out. thanks
Anton Sterenborg M Eng

here's a view of what i want basically:
Public Sub AddOccurrence()
' open assy
Set oAssy = ThisApplication.Documents.Open("C:\Temp\Assy.iam", True)

' Set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

Set oMatrix = Inventor.GetApp.TransientGeometry.CreateMatrix

' Add the occurrence.
Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences.Add("C:\Temp\Part1.ipt", oMatrix)

' open a subassy
Set oSubAssy = ThisApplication.Documents.Open("C:\Temp\SubAssy.iam",
True)
oSubAssy.close

Set oMatrix = Inventor.GetApp.TransientGeometry.CreateMatrix

' Add the subassy to assy.iam
Dim oOcc1 As ComponentOccurrence
Set oOcc1 = oAsmCompDef.Occurrences.Add("C:\Temp\ SubAssy.iam ",
oMatrix)

End Sub
0 Likes
Message 3 of 7

Anonymous
Not applicable
there's nothing wrong with the code, in the original i have no spaces around SubAssy.iam (and yes i mean to write ThisApplication)
0 Likes
Message 4 of 7

Anonymous
Not applicable
I tried your code again in R10 as well as in R11 and still wasn't able to
reproduce the problem. So there may be a specific workflow issue here. Could
you perhaps try with other files?

Sanjay-

wrote in message news:5232987@discussion.autodesk.com...
there's nothing wrong with the code, in the original i have no spaces around
SubAssy.iam (and yes i mean to write ThisApplication)
0 Likes
Message 5 of 7

mitcham_boy
Enthusiast
Enthusiast

i've had similar problems since switching from 2010 to 2013 and now my codes fail with the following error message

 

run-time error '-2147467259 (80004005)'

method 'Add' of object 'ComponentOccurrences' failed

 

 

I haven;t a scooby what to doo

can anyone shed some light ??

 

thanks

dan

0 Likes
Message 6 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

I did not hear any issue of this method. Does this problem occur with any document, even a simplest one? I'd suggest you firstly give a test with a new assembly and add a simple part. If it occurs with specific documents, could you provide a non-confidential copy here?

 

In addition, have you installed SP1.1 of Inventor 2013. just in case the RTM hit an issue we never know.

0 Likes
Message 7 of 7

mitcham_boy
Enthusiast
Enthusiast

confession time ....

 

user error 😞

 

sorry for wasting your time people ... i had set the string variable "my_path" to the wrong folder and hence the add method couldn't find the relevant file  - what a donut !

0 Likes