Error while adding iAssembly members to occurrences

Error while adding iAssembly members to occurrences

SaddamShaikh77
Advocate Advocate
603 Views
5 Replies
Message 1 of 6

Error while adding iAssembly members to occurrences

SaddamShaikh77
Advocate
Advocate

I am trying to add iAssembly occurrences but it is throwing an exception. Please find the below code

AssemblyDocument oDoc = (AssemblyDocument)invApp.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject, "", false);
ComponentOccurrences oOccs = oDoc.ComponentDefinition.Occurrences;
Matrix oPos = invApp.TransientGeometry.CreateMatrix();
double oStep = 0;

iAssemblyFactory oiAssemblyFactory = assmComponentDefinition.iAssemblyFactory;
var tableRowCount = oiAssemblyFactory.TableRows.Count;

for (double iRow = 1; iRow <= (oiAssemblyFactory.TableRows.Count); iRow++)
{
oStep = oStep + 10;
oPos.SetTranslation(invApp.TransientGeometry.CreateVector(oStep, oStep, 0), false);

string filenameis = assmDocument.DisplayName;
string getParent=Directory.GetParent(assmDocument.FullDocumentName).FullName;
string parentPath = getParent + "\\" + System.IO.Path.GetFileNameWithoutExtension(assmDocument.DisplayName);
if (!Directory.Exists(parentPath))
{
Directory.CreateDirectory(parentPath);
}

//Exception at below line
ComponentOccurrence occs = oOccs.AddiAssemblyMember(assmDocument.FullDocumentName, oPos, iRow);

Also same code is working for exporting 2D drawing views and step files but failed for 3D export on the same system.
I have reinstalled Inventor and also run it in Administrative mode but it didn't work for me.
Please help for this

 

Attachment

 

 

0 Likes
604 Views
5 Replies
Replies (5)
Message 2 of 6

johnsonshiue
Community Manager
Community Manager

Hi! Are you using iLogic rule to edit the iAssembly factory table? Have you tried the workflow manually? Does it work? Please share the files here so forum experts can help take a look.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 6

SaddamShaikh77
Advocate
Advocate

Hello,
Thanks for the reply.
I have tried workflow manually and it worked. The same function is working in another addin for 2D dwg export but failed for 3D dwg export on the same system.

Attaching the zip for iam files.

0 Likes
Message 4 of 6

johnsonshiue
Community Manager
Community Manager

Hi Saddam,

 

Do you mind walking me through the exact manual workflow you attempted? I would to see if I can reproduce it on my machine.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 5 of 6

SaddamShaikh77
Advocate
Advocate

Hello Johnson,

I have created a directory of the file name at input location and added manually occurrences that same should work with API mentioned above.

It is not working though. Please find screenshots below

0 Likes
Message 6 of 6

johnsonshiue
Community Manager
Community Manager

Hi Saddam,

 

I am sorry I am still having trouble understanding the workflow. It looks like you have iAssembly member files generated in the factory-named folder. How do I trigger the error?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes