ilogic to find the next free cell in excel

ilogic to find the next free cell in excel

Anonymous
Not applicable
4,432 Views
11 Replies
Message 1 of 12

ilogic to find the next free cell in excel

Anonymous
Not applicable
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.
0 Likes
Accepted solutions (3)
4,433 Views
11 Replies
Replies (11)
Message 2 of 12

xiaodong_liang
Autodesk Support
Autodesk Support

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.

 

 

0 Likes
Message 3 of 12

jdkriek
Advisor
Advisor

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.


0 Likes
Message 4 of 12

Anonymous
Not applicable

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

0 Likes
Message 5 of 12

jdkriek
Advisor
Advisor
Accepted solution

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

Anonymous
Not applicable

It worked like a charm jdkriek thanks sooooooooooooo much  🙂

0 Likes
Message 7 of 12

jdkriek
Advisor
Advisor
Accepted solution

You're quite welcome, glad I could help 😉

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


0 Likes
Message 8 of 12

MechMachineMan
Advisor
Advisor
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
0 Likes
Message 9 of 12

ulas.deniz
Contributor
Contributor

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.
0 Likes
Message 10 of 12

A.Acheson
Mentor
Mentor

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
0 Likes
Message 11 of 12

MechMachineMan
Advisor
Advisor
Accepted solution
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
0 Likes
Message 12 of 12

ulasdeniz
Mentor
Mentor

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

0 Likes