Hi
I have an Assembly configurated with iLogic. This assy is to be copied into new numbers for each variaty that will be made in the future. I would like the Assy and 2 specific parts to be copied, and named according to the new number.
Example.:
Master.iam
L Master-1.ipt
L Master-2.ipt
L 90010.ipt
L 90012.ipt
Becomes.:
80025.iam
L 80025-1.ipt
L 80025-2.ipt
L 90010.ipt
L 90012.ipt
The 900xx numbers should not be copied, as they are standard parts, which is used all around our CAD...
When the code is lauched, it should afterwards have the "new" assy active, hence the Save As
Is it possible to have iLogic or VBA do this for me..?
/LSA
This can be done using FileDescriptor.ReplaceReference method.
Look at this post please
http://adndevblog.typepad.com/manufacturing/2012/08/replace-the-file-reference-by-inventor-api.html
Hi Vladimir
Thanks for your reply. I checked out the site, and tried to get an idea of how i should do it, but im affraid i need a little more help to get started...
Here is how i think it should be done, please correct me if im wrong.. 🙂
first "Save copy as" on the 2 specific parts.
then "Save as" for the assy
Then replace the 2 parts in the assy with the 2 new ones that has just been created...
I got this from looking at the site, but im not realy sure what that the code there actually does. Is it the same as Component.Replace() in iLogic, only in VBA??
/LSA
I believe iLogic function Component.Replace() is equivalent to VBA ComponentOccurrence.Replace(FileName As String, ReplaceAll As Boolean) method.
You may find the discussion and the sample for FileDescriptor.ReplaceReference here;
Cheers,
Hehe you linked to the same thread.. 😄
I have been looking for a way to Simply copy a specific part in my assy. but can't seem to find a rule that does this...
Something like
ThisDoc.Document.SaveAs(NewFileNameAndExtension , True)
but where ThisDoc.Document is replaced with xxx.ipt
/LSA
Now i found a way to copy the 2 specific parts in my assy. But im now struggeling with getting the Assy copy to work The Bold Line... though it should be straight forward...?! any ideas?
Sub Main()
Dim Path As String = ThisDoc.Path & "\"
Dim FileChange As Boolean = False
InvDoc = ThisDoc.Document
Dim refDocs As DocumentsEnumerator = InvDoc.AllReferencedDocuments
Dim refDoc As Document
Dim PartN As String = "80061"
For Each refDoc in refDocs
If refDoc.DisplayName.EndsWith ("-2")= True Then
MessageBox.Show(refDoc.DisplayName)
NewFileName = PartN & "-2.ipt"
refDoc.SaveAs(Path & NewFileName, True)
End If
If refDoc.DisplayName.EndsWith ("-1")= True Then
MessageBox.Show(refDoc.DisplayName)
NewFileName = PartN & "-1.ipt"
refDoc.SaveAs(Path & NewFileName, True)
End If
Next
ThisDoc.Document.SaveAs(Path & PartN, False)
iLogicVb.UpdateWhenDone = True
End Sub
For some reason it looked at the 2 specific parts diffrently than all other parts in the assy, it didn't see the extension on them... took me some time to work that out...
I looked at your code and you were just missing the file extension on the assembly saveas. Also I changed the saveas for the parts to be false. This way the parts are replaced. Test it and see how it works.
Dim Path As String = ThisDoc.Path & "\"
InvDoc = ThisDoc.Document
Dim refDocs As DocumentsEnumerator = InvDoc.AllReferencedDocuments
Dim refDoc As Document
Dim PartN As String = "80061"
For Each refDoc in refDocs
'MessageBox.Show(refDoc.DisplayName)
If refDoc.DisplayName.EndsWith("-2.ipt")= True Then
'MessageBox.Show("found2")
NewFileName = PartN & "-2.ipt"
refDoc.SaveAs(Path & NewFileName, False)
ElseIf refDoc.DisplayName.EndsWith("-1.ipt")= True Then
'MessageBox.Show("found1")
NewFileName = PartN & "-1.ipt"
refDoc.SaveAs(Path & NewFileName, False)
End If
Next
ThisDoc.Document.SaveAs(Path & PartN & ".iam", False)
iLogicVb.UpdateWhenDone = True
Dan
I have created a Template Assembly
This assembly is ruled by parameters on excel and I-logic, it has parts that are standard and parts that are nonstandard that change geometry every time parameters are changed.
I’m trying to implement a programing option via I-logic or VBA that will allow the users, to enter a top level Part number and
Automatically generate a (copy of the engineering document) of this template assembly and at the same time automatically (replace with copy the nonstandard components) using Productstream.
the code that I found on the blog below from (Assembly Save As incl. some parts With iLogic or VBA)
works good outside Productstream but not integrated any idea how to integrate Ilogic and productstream to generate these files.
Thanks
Dim Path As String = ThisDoc.Path & "\"
InvDoc = ThisDoc.Document
Dim refDocs As DocumentsEnumerator = InvDoc.AllReferencedDocuments
Dim refDoc As Document
Dim PartN As String = "80061"
For Each refDoc in refDocs
'MessageBox.Show(refDoc.DisplayName)
If refDoc.DisplayName.EndsWith("-2.ipt")= True Then
'MessageBox.Show("found2")
NewFileName = PartN & "-2.ipt"
refDoc.SaveAs(Path & NewFileName, False)
ElseIf refDoc.DisplayName.EndsWith("-1.ipt")= True Then
'MessageBox.Show("found1")
NewFileName = PartN & "-1.ipt"
refDoc.SaveAs(Path & NewFileName, False)
End If
Next
ThisDoc.Document.SaveAs(Path & PartN & ".iam", False)
iLogicVb.UpdateWhenDone = True
No there's no way to have iLogic code connect to the Productstream (Vault Pro) do this. You will need to create a .NET addin that will connect to Productstream to do this. iLogic is only meant to work in Inventor. If what you are planning to do is copy an assembly and it's components and rename the files to new file names, any particular reason why Copy Design in Productstream is not used? Just curious.
Dan
Dan
This code works really good for top level components, I would like to replace a subassembly and also replace a componet ipt inside that subassembly using similar code, could you please give me an example or a reference, I have been searching but have not succes finding a similar application for subassemblies and their components.
Thanks
TS
Dan
I wanted to reach out to you and see if you can help me with this question
I’m currently using the code of this inventor customization link and it works good, I have some template assemblies and I’m able to automatically replace with copies some of the components or subassemblies that need changes in size.
It works really well replacing the parts or subassemblies from the top level template assembly, the issue I have is that first I need to replace a subassembly and once that subassembly is replaced I need to replace a part inside that subassembly.
So I need this code to run twice first to replace the selected child parts or subassemblies of the top assembly and then replace some parts of the subassemblies replaced during the first cycle and also to save those changes.
I was thinking about a code that indicate if a specific subassembly or part file name is not found in the assembly then trigger the code to run again, so far I have not found code that can trigger that option, I tried to trigger the rule the first time when the assembly opens and the second time before is saved but it doesn’t save the subassembly that contains the part just replaced during the second cycle.
I don’t want to use component.isActive because I’m not working with leves of detail in my assembly
Thanks for your help I appreciate your comments
Tatiana S