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 to find the next free cell in excel

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Fleagle8t
3778 Views, 11 Replies

ilogic to find the next free cell in excel

Hi folks,

What im trying to do is take the iproperties from an inventor .dwg, and place them into a specific excel spreadsheet.
I've managed to get so far, by using code that Curtis posted, which does the opposite of what im looking to do.The code Curtis posted takes info from excel and fills in iprops.
I can fill in specfic cells, for instance columns A, B & C on Row 1 and place that info into a specific spreadsheet.
But my code falls down when i run the code on another .dwg, It obviously overwrites what was previously in those cells.... I am looking for the code that looks to see if those cells are in use, and if so, go to the next available cell down.
Or if anyone has done this before and would be so kind as to share your knowledge it would be greatly appreciated.
Many thanks.
11 REPLIES 11
Message 2 of 12
xiaodong_liang
in reply to: Fleagle8t

Hi,

 

It sounds like a question of Excel API only, instead of Inventor API. You may have to consult with Excel. But if you could clarify a bit on "cells are in use", probably some peers here would be able to give some comment.

 

 

Message 3 of 12
jdkriek
in reply to: xiaodong_liang

Fleagle,

Can you post your code? There's a few ways to do this, but it depends on your method.

 

Xiaodong Liang,

He means is the cell empty or not.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 4 of 12
Fleagle8t
in reply to: jdkriek

Hi jdkriek,

 

 Thanks for your reply, please see below for the code im running (very basic).

StartRule:

 
'read excel file
 Worksheet=("C:\Workspace\00Vault\ACE-02001- ACE-02500\ACE-02380\ACE-02380-080017")
 Sheetno= ("Sheet1")
GoExcel.Open(Worksheet, Sheetno)


For row = 2 To 10000

If GoExcel.CellValue("A" & row) = "" Then GoExcel.CellValue("A" & row) =iProperties.Value("Project", "Part Number")
If GoExcel.CellValue("B" & row) = "" Then GoExcel.CellValue("B" & row) =iProperties.Value("Project", "Revision Number")
If GoExcel.CellValue("D" & row) = "" Then GoExcel.CellValue("D" & row) =iProperties.Value("Status", "Eng. Approved Date" )
If GoExcel.CellValue("F" & row) = "" Then GoExcel.CellValue("F" & row) =iProperties.Value("Project", "Description")


Exit For 

Next



GoExcel.Save

 As you will notice there has to be an excel file already saved in the location specified in the 'Worksheet' section of the code...

Any help would be Brilliant!!!

Message 5 of 12
jdkriek
in reply to: Fleagle8t

The code you are using really isn't intended to do what you want.

 

Wrote this real quick, hope it helps.

 

Worksheet = ("C:\Workspace\00Vault\ACE-02001- ACE-02500\ACE-02380\ACE-02380-080017")
Sheetno = ("Sheet1")
' Open excel 
GoExcel.Open(Worksheet, Sheetno)
' Define Range
RowStart = 2
RowEnd = 100
For count = RowStart To RowEnd
	' If it's blank count it
	If String.IsNullOrEmpty(GoExcel.CellValue("A" & count)) Then 
		i = i + 1
	End If
Next
' Next empty row is max rows minus blank rows plus one
row = RowEnd - i + 1
MsgBox("Inserting Data on Row " & row)
GoExcel.CellValue("A" & row) = iProperties.Value("Project", "Part Number")
GoExcel.CellValue("B" & row) = iProperties.Value("Project", "Revision Number")
GoExcel.CellValue("D" & row) = iProperties.Value("Status", "Eng. Approved Date")
GoExcel.CellValue("F" & row) = iProperties.Value("Project", "Description")
GoExcel.Save
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 6 of 12
Fleagle8t
in reply to: jdkriek

It worked like a charm jdkriek thanks sooooooooooooo much  🙂

Message 7 of 12
jdkriek
in reply to: Fleagle8t

You're quite welcome, glad I could help 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 8 of 12
MechMachineMan
in reply to: jdkriek

Hey! I tried using this code and modifying it, but it keeps telling me I can't use the Row type in an expression. (or something along those lines). Was wonder if you could help me out, please and thanks!

The code is:
'creating dummy properties for the user and filename to use in next rule
SharedVariable("Path")= ThisDoc.PathAndFileName(True)
iProperties.Value("Custom", "Draftsman")= ThisApplication.GeneralOptions.UserName

'my attempt at using an input box with a temporary variable to store my change notes
SharedVariable("REVI")= InputBox("What did you change?", "REV", "")

'runs next rule
'iLogicVb.RunRule("EXCEL LOG")

Worksheet = ("C:\Documents\Excel File Log")
Sheetno = ("Sheet1")
' Open excel
GoExcel.Open(Worksheet, Sheetno)
' Define Range
RowStart = 2
RowEnd = 100
For count = RowStart To RowEnd
' If it's blank count it
If String.IsNullOrEmpty(GoExcel.CellValue("A" & count)) Then
i = i + 1
End If
Next
' Next empty row is max rows minus blank rows plus one
row = RowEnd - i + 1
GoExcel.CellValue("A" & row) = TimeString
GoExcel.CellValue("B" & row) = DateString
GoExcel.CellValue("C" & row) = iProperties.Value("Custom", "Draftsman")
GoExcel.CellValue("D" & row) = SharedVariable("REVI")
GoExcel.CellValue("E" & row) = SharedVariable("Path")
GoExcel.Save

--------------------------------------
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 9 of 12
ulas.deniz
in reply to: jdkriek

it says  "Error on Line 31 : 'row' is a type and cannot be used as an expression". How can I a solve this?

Ulas Deniz
BIM Consutant
Turkey Izmir.
Message 10 of 12
A.Acheson
in reply to: ulas.deniz

Hi @ulas.deniz 

Can you post the code your using to determine what line 31 is?

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 11 of 12
MechMachineMan
in reply to: A.Acheson

Try using the same code, but replace 'row' with 'currow' or something other
than row.

'Row' is a 'protected' word in the code which is why it's getting confused.

--------------------------------------
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 12 of 12
ulasdeniz
in reply to: MechMachineMan

Thanks. I did it yesterday like you said.


Ulaş Deniz


Forumlarımızda çözülen sorularınızı "ÇÖZÜM OLARAK KABUL ET" ( "ACCEPT AS SOLUTION" ) seçimiyle işaretlemeyi lütfen unutmayın.
Beğendiğiniz mesajları lütfen "Övgü Puanı" (KUDO) ile ödüllendirin.
Youtube : https://www.youtube.com/channel/UCkJpVueGScmJvW1RIgqttSg

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

Post to forums  

Autodesk Design & Make Report