iLogic-Can't Copy and save an Assembly under the same name as a deleted Assembly

iLogic-Can't Copy and save an Assembly under the same name as a deleted Assembly

Anonymous
Not applicable
811 Views
6 Replies
Message 1 of 7

iLogic-Can't Copy and save an Assembly under the same name as a deleted Assembly

Anonymous
Not applicable

The title is a little complicated so let me try and simplify. I'm using iLogic to create a wall builder. Currently I am trying to copy an assembly of a door from another location to my wall file. It worked once, but I deleted the door file and tried to recreate it and it gives me this error

Capture2.PNG

It works for a unique name but if I delete the door file from the wall file, I can't recopy the file under the same name.

Here's my code.

 

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument


Dim oDef As AssemblyComponentDefinition
oDef = oDoc.ComponentDefinition

'---------------------------------------------------------------------------------------------------------
		 
Dim oOcc As ComponentOccurrence

Dim Dcounter As Integer
Dcounter = 0

For Each oOcc In oDoc.ComponentDefinition.Occurrences
   
   If oOcc.Name.Contains("DOOR") Then
   
   Dcounter = Dcounter + 1

	End If

Next

Dim nextdoor As Integer
nextdoor = Dcounter + 1

Dim nextdoorname As String
nextdoorname = "DOOR" & nextdoor

Dim DocPath As String
DocPath = ThisDoc.Path & "\"

Dim DoorPath As String
DoorPath = "Z:\DRAWINGS\INVENTOR MODELS\2000-XXXXX (KITS, WEDLEMNTS)\29XX-XXXXX FR\DOOR\DOOR MAKER.iam"

Dim NewDoorPath As String
NewDoorPath = DocPath & nextdoorname & ".iam"

Dim oDoorDoc As AssemblyDocument

Try

	Try
		
		oDoorDoc = ThisApplication.Documents.Open(DoorPath, False)
	    
	Catch
	        
		MessageBox.Show("Could not find " & DoorPath)
	    
	End Try

	Try
		
	oDoorDoc.SaveAs(NewDoorPath, True)
	oDoorDoc.Close
	    
	Catch ex As Exception    
	        
		MessageBox.Show(ex.ToString())
		MessageBox.Show("COULD NOT COPY") 
	    
	End Try


	Catch
	
		MessageBox.Show("Failed")

End Try
0 Likes
812 Views
6 Replies
Replies (6)
Message 2 of 7

HermJan.Otterman
Advisor
Advisor

I did see your error, but don't see exactly what you want to do. I don't see the deletion of a file.

I made the folling assumption:

- You have a Main Assembly (= oDoc),

- in this main assembly there is a door subassembly (= oOcc), with parts in it

(I got the error when this door sub assy was a part)

- DoorPath is the path to your Master door Assembly, that needs to be copied

so you open it in Inventor and save it to the location of the main assy and then close it..

 

you don't place it in your assy so the next time you run this the number (Dcounter) is still the same, even then I don't get the error any more.

 

So I checked my code again with yours and there are (almost) no differences

 

maybe an other way to copy a file without opening it in inventor:

Dim AssyInfo As New System.IO.FileInfo(Assyfullfilename) 'this would be the path to the "door_maker.iam"
Dim newAssyInfo As System.IO.FileInfo = AssyInfo.CopyTo(newAssyFullFilename, True) 'this would bet the new path

 

after this you need to place the file in the assy

 

 

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 7

Cosmin_V
Advocate
Advocate

Are you using Vault?

0 Likes
Message 4 of 7

Anonymous
Not applicable

I was placing the door in the assembly, but I left that part out as my code was failing at the copy and move stage. I deleted the file manually, not with ilogic.

 

Weirdly enough, I'm not having this issue or error anymore. I'm not aware of any changes other than the computer being restarted.

 

I will try your method of copying though.

0 Likes
Message 5 of 7

Anonymous
Not applicable
Thank you, this is the only successful way I've been able to copy my sub assemblies.
0 Likes
Message 6 of 7

WCrihfield
Mentor
Mentor
Have you considered using the built-in tool for this called "iLogic Design Copy"? Below are a couple of links to the online help pages that talk about it. https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-0BE1A21F-E2B4-4442-A4B9-F48C26210795 https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-ABFC1613-9A55-4772-B919-C530DC7D6973

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 7

Anonymous
Not applicable
This was an iLogic code problem. Copy design is great all in all. Just working with automated assemblies.
0 Likes