Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Control naming in place ilogic component command

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
dave
1359 Views, 7 Replies

Control naming in place ilogic component command

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

7 REPLIES 7
Message 2 of 8
waynehelley
in reply to: dave

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

 

 

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Tags (1)
Message 3 of 8
waynehelley
in reply to: dave

Sorry, I just realised I scanned over your problem a tad too quickly and misunderstood what you were asking!

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 4 of 8
philippe.leefsma
in reply to: dave

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 developer center

 

My First Inventor plug-in

 

Inventor API Training Material on Github

 

ADN Inventor DevBlog

 

I hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 8
dave
in reply to: philippe.leefsma

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....

Message 6 of 8
philippe.leefsma
in reply to: dave

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 7 of 8
dave
in reply to: philippe.leefsma

Going to give it a try. Thank you for your advice on this.

Message 8 of 8
andrescastellanosint
in reply to: dave

Hi Dave you could share your full code?

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

Post to forums  

Autodesk Design & Make Report