Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Importing Text User paramaters from excel

3 REPLIES 3
Reply
Message 1 of 4
paul.mcnam
907 Views, 3 Replies

Importing Text User paramaters from excel

Hi all,

 

I'm developing a rather complex excel spreadsheet that allows me to have full control of an assembly.

This involves straight number inputs for dimensions, as well as text inputs for component colour, part numbers and descriptions.

 

As my research and experimenting shows, you can't directly import text from excel into a User Parameter like you can with numbers.

You need to create an iLogic rule that specifies a unique cell number in your sheet and then assign it to a manually created User Parameter.

This is time consuming but also problematic as if you update the excel sheet and the cell location moves, your text import stops working.

The only compromise I have is that I use a different input sheet where I can continually update, format, move rows and cells around etc, and then link the outputs to a fixed sheet i call "Text_Output". On that sheet i put clear instructions to not move any cells around.

 

Do we have any idea why this is the case? I understand that text was only added to iPart functionality around 5 years ago, so perhaps it's just something left behind that will be updated soon?

It will just be very frustrating to code the text import in all my relevant assemblies only to have this issue corrected shortly after, but i'd prefer this were sooner than later.

 

Is there a way to put in suggestions to Autodesk? This one seems a bit of a no brainer, but some extra noise from users may not hurt

 

Cheers

Paul

3 REPLIES 3
Message 2 of 4
MechMachineMan
in reply to: paul.mcnam

Write your program in VBA and run it from excel then?

 

Or connect to the excel application through your iLogic program and use the features/named ranges to find necessary cells.


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 4
CadUser46
in reply to: paul.mcnam

I was going to say the same as Justin.  Used named ranges instead of explicit cell references.  ie Range("FaceColour") instead of Cells("B7")

I think you could even concatenate named ranges in case Excel doesn't allow you to have the same name on more than one sheet. ie FaceColour + PartName

 

Alternatively you could set your entire spreadsheet to text then use CInt(NamedRange) in VBA to convert the ones you expect to be numbers.

 

 


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

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Message 4 of 4
paul.mcnam
in reply to: MechMachineMan

I suppose this would be a workaround, but it still gets a bit messy having to name all the cells and then having to write VBA.

As it stands, having column A as the name of the user input and column B with the numeric input, it's simple, works, and requires no coding to import.

I'm also trying to limit the complexity and amount of coding as for one, I have little coding expertise and similarly not many of my colleagues do, so I want this project to be easy for someone else to understand and be able to modify at a later date. Having three seperate ilogic rules, one for text import, one for colour, and one for iProperties, even though they are just one line each, is really the limit to the complexity I'm hoping to have within the files.

So yeah I'm really just wondering why we can't import text as we can numbers, I find it bizzare and was hoping someone from Autodesk could respond.

 

ps. a nice little trick i figured out for those who use excel and are importing text, I worked out how to ensure the ilogic rules always get triggered in your assembly, even if none of the numeric model parameters change (i.e. you can select the "any model parameter change" trigger, however if you're updating only text input, inventor doesn't know you've changed any inputs until the ilogic code for text import is actually run). What i did was I created a new numeric user parameter in excel called "Refresh_trigger" (cell A1), and have any number for it, say "0" (Cell B1). Then I added this code to This Workbook in VBAproject which adds 1 to the value in B1 each time you press save 

 

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Sheets(1).Range("B1").Value = Sheets(1).Range("B1").Value + 1

End Sub

 

I then created a sketch that uses this dimension and hid the sketch. I added the rules to the "any model parameter change" event trigger and now pressing save updates my assembly. Interestingly for the ThisDoc.Document.Rebuild() or iLogicVb.UpdateWhenDone = True, to update the whole assembly, i need to press save twice in my excel sheet for the size changes to occur.

 

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report