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: 

iLogic w/ith Embedded Excel spreadsheet

8 REPLIES 8
Reply
Message 1 of 9
PunkR0ckz000
929 Views, 8 Replies

iLogic w/ith Embedded Excel spreadsheet

Hello everyone!

 

I would like to automate furthermore the way our Part Number works.

 

Right now, we want to be able to add an embedded excel spreadsheet to our models and AUTOMATICALLY set that part's Part Number to the cell B1 in it... if there is no embedded excel spreadsheet, the Part Number should be it's filename (without extensions obviously).

 

Right now, I have a simple line of code that reads the first line of an embedded excel spreadsheet and sets its Part Number to the value...

I have 2 problems though with the following line...

 

1st problem is: How can I automatically find the 1st spreadsheet in the part and retrieve it's B1 cell? If I delete this embedded excel spreadsheet and insert another one, it will be Embedding 3 and won't be retrieved by the iLogic line that I have right now...

 

2nd problem: If there are no embedded excel spreadsheet, I still need to set automatically it's part number to filename w/o extension... I can't find a line to do this...

 

Heres the line of code that I have right now...

iProperties.Value("Project", "Part Number") = GoExcel.CellValue("3rd Party:Embedding 2", "Sheet1", "B1")
8 REPLIES 8
Message 2 of 9
PunkR0ckz000
in reply to: PunkR0ckz000

please help!

Message 3 of 9
jddickson
in reply to: PunkR0ckz000

Try this out it should solve problem #2

 

Try

  iProperties.Value("Project", "Part Number") = "=" & GoExcel.CellValue("3rd Party:Embedding 2", "Sheet1", "B1")
  
Catch
End Try

 

I hope this helps.

 

 

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Message 4 of 9
PunkR0ckz000
in reply to: jddickson

jddickson; thanks for the reply, it works 50% of what I would like it to work (for problem #2). the problem is, if I add a spreadsheet and run the rule, it works, but then if I delete the spreadsheet, it doesn't change to Hello for example if the part is called Hello.ipt ..

I have never seen a "Try/Catch/End Try" before, so I am unsure on how to add something to "automate" the filename part ...I would guess it works like an If/ElseIf/Else/End If, but I am unsure...
Message 5 of 9
jddickson
in reply to: PunkR0ckz000

I’m still trying to figure out the answer to your #1 problem.

 

Try / Catch will try to run the rule and if it fails then it will do nothing.  

Message 6 of 9
PunkR0ckz000
in reply to: jddickson

ok so, if I understand correctly how it works...
'Get from filename here (because, if there is an excel spreadsheet, I want it to override the part number, so it should be run after this one...)
Try
'Get from excel spreadsheet here
Catch
End Try

That would be right, I would say, am I wrong? (Just trying to clarify this Try/Catch thing) and thanks for helping me with that! I really hope I can find a way for the spreadsheet names, as other workers at my shop don't know how iLogic works and I'm limited in programming... only programmed IRC scripts back in the days, lol!
Message 7 of 9
jddickson
in reply to: PunkR0ckz000

First of all there are a lot of better ways to write the code in this part but this should work. This might not be what you were asking for but it might make something’s easier.

 

In the User Parameters there is a (Embedded_Number) Parameter that’s a multi list drop down. If it reads “0” then the part name will be the same as your file name. Whenever you embed an Excel sheet you will have change the Parameter to match the sheet number.

 

pic 9.jpg

 

I hope this helps in some way.

 

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Message 8 of 9
PunkR0ckz000
in reply to: jddickson

Sorry, I can't really accept this solution but I thought about something similar...
Creating a variable that is 1 if there is an OLE document (excel spreadsheet) and 0 if there is none and apply the correct value (Filename or B1) to the Part Number... but it wouldn't help with the "find automatically the 1st spreadsheet" thing... 😞
Message 9 of 9
PunkR0ckz000
in reply to: PunkR0ckz000

Anyone else? still need help on it 😞

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

Post to forums  

Autodesk Design & Make Report