Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Save file crashes

7 REPLIES 7
Reply
Message 1 of 8
WHassan
2332 Views, 7 Replies

iLogic Save file crashes

Hello,

 

I seem to have my task accomplished, but Inventor crahes on me after it is done.

Here is how my iLogic works.

 

 

 

' Deleting the suppressed parts from the assembly

 

Dim compDef as AssemblyComponentDefinition

compDef = ThisDoc.ComponentDefinition

 

Dim compOcc as ComponentDefinition

 

For Each compOcc in compDef

   If compOcc.suppressed = true then

        compOcc.Delete

   End if

Next

 

 

' Saving a copy of the assembly components

 

Dim refDocs as DocumentsEnumerator=ThisDoc.Document.AllReferencedDocuments

 

Dim compCount As Integer = refDocs.Count

 

For j = 1 to compCount

    refDocs.item(j).SaveAs( "C:\MyPath\Parts\Part" & j & ".ipt", False)

Next

 

 

' Saving a copy of the assembly document

 

ThisDoc.Document.SaveAs( "C:\MyPath\Assembly\Pallets.iam", False)

 

 

 

 

 

Now as soon as the last line is executed, Inventor crashes.

But when I go to the save file part (C:\MyPath), both the parts and assembly files are saved and if I open it, they work just fine.

 

I just can't get inventor to stop crashing.

 

All help is appreciated. Thanks

 

Wajih

 

 

 

Tags (3)
7 REPLIES 7
Message 2 of 8
mrattray
in reply to: WHassan

Does it crash if you change the saveas argument for save copy as to true?

It works on my test part (without the preceding code).

Does it crash if you comment out the loop that saves off copies of the parts?

Mike (not Matt) Rattray

Message 3 of 8
WHassan
in reply to: mrattray

Hi Mike,

 

I have tried several attempts.

 

Does it crash if you change the saveas argument for save copy as to true?

 

Yes, if I set it true for the parts;

In the newly saved assembly, the assembly is composed of the the orginal parts rather than the newly saved parts.

 

If I set it true for the Assembly document it saves is and it still crashes, thus I cannot tell if opens up the new assembly or sticks with the old one.

 

It works on my test part (without the preceding code).

 

Thats the strange part, I have the same code (Copied) on anther assembly, but it does not have the part where it deletes the suppressed parts. and no problems with that what so ever.

 

Does it crash if you comment out the loop that saves off copies of the parts?

 

Yes, again. In fact I put up msgbox at each step and saving the part files seems to be working fine. It crashes right after it saves the new assembly document.

 

 

 

I am guessing it has some trouble opening the new file. Probably with something to do with the Level of Detail (but then again, I mightbe way off).

 

I'll keep playing. But thanks again for your time.

 

Message 4 of 8
mrattray
in reply to: WHassan

Can you post the files?

Mike (not Matt) Rattray

Message 5 of 8
WHassan
in reply to: mrattray

I don't know what made it work, but it is a result of any one of the following;

 

1.    I saved the path for the folder paths for the assembly and the part files in two separate variables and refered to them in Save/SaveAs instructions

 

2.    I change the DisplayName of the parts through a separate loop and save the parts exaclty as their display name

i.e.

 

refDocs.item(j).SaveAs(folderPathforParts & refDocs.item(j).DisplayName & ".ipt", False)

 

then

 

ThisDoc.Document.SaveAs(folderPathforAssembly & "MyPallet.iam", false)

 

 

3. I cleared up my desired directory for the parts and the assembly (I ended up with a lot of clutter after several runs)

 

 

Now the rule works just fine.

 

Replaces old files and creates new without a glitch.

 

Thanks for your time. 

Message 6 of 8
Yijiang.Cai
in reply to: WHassan

When using the code lines you provided in iLogic, the error will show. So I update the code lines and run it, works fine. Please see the updated one below. If crash is still reproducible, could you attach the dataset for further investigation?

 

' Deleting the suppressed parts from the assembly

Dim compDef As AssemblyComponentDefinition
compDef = ThisDoc.Document.ComponentDefinition

Dim compOcc As ComponentOccurrence

For Each compOcc In compDef.Occurrences
If compOcc.Suppressed = True Then
compOcc.Delete
End If
Next


' Saving a copy of the assembly components

Dim refDocs as DocumentsEnumerator=ThisDoc.Document.AllReferencedDocuments

Dim compCount As Integer = refDocs.Count

For j = 1 To compCount
refDocs.item(j).SaveAs( "C:\MyPath\Parts\Part" & j & ".ipt", False)
Next


' Saving a copy of the assembly document

ThisDoc.Document.SaveAs( "C:\MyPath\Assembly\Pallets.iam", False)

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
Message 7 of 8
WHassan
in reply to: Yijiang.Cai

Hey River,

 

This is a totally different file (i.e. Not the same file I originally posted about).

But

 

In this new assembly, I am trying to do the same thing and inventor crashes exaclty the same way.

I also tried the crashing behaviour on another computer.

 

I have created a .zip file for you to investigate

 

 

Methods, how to run the file;

 

1. In the Parameters Window, there is a User Paramter (type;True/False) named "saveCopy" set as "False", change it to "True" to execute the iLogic rule named "saveCopy2"

 

Or you can do this

 

2. In the forms window, there is a form which has the same Parameter (as mentioned in method 1), change the value to "True" to run the rule (same rule|| method 1)

 

 

On how to crash:

 

if you use method 2, Inventor would not crash,

if you use method 1, Inventor crashes

 

My inferences:

 

1. In the newly created assembly, the names for the various occurrences (components) change, therefore the rules which address the assembly components still refer to the old names and might be cuasing the crash when Inventor tries to open up the new assemby file.

But I suppressed the rules which are intended to be run before the "saveCopy2" but it still crashes

 

2. if you use method 2, the names for the sub-assemblies in the Browser window do not appear to have changed. But they actually have changed. You can verify that when you close the assembly and open the same back again. Then you see the new names in the Browser window

 

Let me know what I am doing wrong.

 

Thanking you

Wajih

 

Message 8 of 8
Yijiang.Cai
in reply to: WHassan

Many thanks to provide the details and dataset to me for further investigation, and I could reproduce the crash, which has been logged as 1472915 in our tracking system. However one VBA is created based on the iLogic "SaveCopy2". When running the VBA, it does work fine. Please see the attached one.

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report