I'm looking for a simple way to rename a component after using the "Place Ilogic Component" command. This command does everything I need as is except for file naming. The adding of the "-1" or "-2" to the original name as it does automatically doesn't suffice for me to keep my items organized. Here's what I'm currently doing as a manual workaround.... I run the command, select my component, place it, etc. I then save my assembly and afterwords delete that item from my assembly. I then use the place command, and in the window where the items are listed find the "place ilogic" copied item and do a rename, just before double clicking to place it back into my assembly. The item that I am renaming often has child components. Those components, I leave alone and have no need for renaming, I just need to be able to find the parent model easier. Is there any way that after I place using that command, I can rename the component without deleting it. Note: I'm looking to rename the component's file name (not just the name shown in the assembly browser). I'm thinking just a simple ilogic rule which I can place as a button on my ilogic user form. Click the button, have a simple message prompt ask for the name. Something simple. As a novice programmer, I'm trign to keep everything programming-wise in iolgic as it is easy for me to use & understand.
Thanks
Solved! Go to Solution.
Solved by philippe.leefsma. Go to Solution.
hello there, i faced this problem recently too and managed to come up with a way to get around it...
For i= 1 To 10
Try
Component.InventorComponent("Insert the Part Number here" & ":"&i).Name = "Part Name"
Return
Catch
End Try
Next
Basically the code Tries PartNumber:1, if it fails it tries PartNumber:2 etc... and exits when it has been successful
Sorry, I just realised I scanned over your problem a tad too quickly and misunderstood what you were asking!
Hi Dave,
iLogic may seem nice and easy for novice programmers, but it is also not powerful and has a very limited flexibility when it comes to more advanced workflows. Basically you cannot handle any event using iLogic.
Typically the workflow you describe would require setting up event handlers from an add-in. You would need to listen to events such as "AssemblyEvents.OnNewOccurrence" that is fired when a new occurrence is inserted in your assembly. You could also use events such as "UserInputEvents.OnActivateCommand / OnTerminateCommand" to detect the "Place iLogic component" command has been used.
Once the occurrence has been inserted, make a copy of the file with "FileManager.CopyFile", rename the file and replace the reference in your assembly using "FileDescriptor.ReplaceReference" on the correct file descriptor.
You will need a bit more experience with the API that simple iLogic scripting to achieve that feature.
Places where you can start to learn the API:
Inventor API Training Material on Github
I hope that helps,
Philippe.
Makes sense... I was kind of figuring it may need to go beyond ilogic. I'll take a look at the suggestions you've offered to learn more about the API. Would it make sense then to just build my own tool for doing the copy design, totally taking the "place ilogic component command" out of the equation? Would that be an easy build, or would it make more sense to still use the "place ilogic component" command to do the actual copy, then rename & reset references?
Thanks for your help....
You may want to keep the original command as it involves a specific selection dialog that will require quite a bit of re-work if you implement from scratch. Using events as I mentioned previously to act upon command completion should be a relatively straightforward task for somebody who know the API.
You can also create a custom command (your own button) that invokes the native place component, for example if you have to perform some preliminary steps. Or replace the original command with your own in the UI...
http://adndevblog.typepad.com/manufacturing/2012/07/replacing.html
Regards,
Philippe.