using iLogic to populate iProperties "Project" field is unpossible

using iLogic to populate iProperties "Project" field is unpossible

Anonymous
Not applicable
1,250 Views
6 Replies
Message 1 of 7

using iLogic to populate iProperties "Project" field is unpossible

Anonymous
Not applicable

(Inventor 2017) I’m attempting to automate the population of some iProperties I use for my parts, which then populate fields in my drawings.  My company uses charge numbers for billing time, which I’ve been recording in the iProperties “Project” text box on the Project tab.

 

I modified some of Curtis Waguespack’s code I found here (thank you, Curtis), to pull a list of charge numbers from an excel sheet into a multi-value parameter named “chargeNumbers” (my code below).All is good so far. 

 

He included an input list box that I wanted to keep, too (thank you, Curtis) and I wanted to populate the iProperties “Project” parameter with that selection BUT….it seems that iLogic cannot access that parameter.  The error I get is " 'Project' is not a member of 'Autodesk.iLogic.Interfaces.IiProperties'."

 

I’ll not bother to ask why one isn’t allowed to access that parameter, if that's the case; instead, does anyone know another way to accomplish this last step?  Can I define my own iProperty called “Charge Number” and populate it by iLogic?  Is there a Curtis-level line of code that lets me get at the iProperty I want?  Should I just keep doing it manually instead of braining my damages with iLogic?

 

Much appreciation for any ideas,

Andrew

 

iLogicVb.UpdateWhenDone = True
'check For Parameter and create If Not found
Try
'get parameter value (just to see if it exists)
oTest = Parameter("chargeNumbers")
Catch
' Get the active document. Assumes a part document is active.
Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument
' Get the UserParameters collection
Dim userParams As UserParameters
userParams = partDoc.ComponentDefinition.Parameters.UserParameters
'create the parameter
oParam = userParams.AddByValue("chargeNumbers", "g-job", UnitsTypeEnum.kTextUnits)
End Try
'Set the list
MultiValue.List("chargeNumbers") =  GoExcel.CellValues("chargeNumbers.xlsx", "Sheet1", "A1", "A10")
'Get user input and set number
iProperties.Project = InputListBox("Choose a number.", _
MultiValue.List("chargeNumbers"), MultiValue.List("chargeNumbers").Item(0), "iLogic", "List of charge numbers:")

 

0 Likes
Accepted solutions (2)
1,251 Views
6 Replies
Replies (6)
Message 2 of 7

rhasell
Advisor
Advisor
Accepted solution

Hi there

 

I did a little testing for you.

 

Try this, replace your last line with the following two lines, see if it works.

Due to my lack of skill I tend to split the commands up, its easier to debug.

 

oTEST = InputListBox("Prompt", MultiValue.List("chargeNumbers"), oTEST, Title := "Title", ListName := "List")
iProperties.Value("Project","Project")=oTEST

 

 

Reg
2026.1
Message 3 of 7

Anonymous
Not applicable

Hey thanks, rhasell.  Your code gets an error from the .NET Framework "Object reference not set to an instance of an object" but it does populate that iProperty. You still get credit for the win.

Cheers,

A

Message 4 of 7

Curtis_Waguespack
Consultant
Consultant

Hi QuasiMojo,

 

I'm a little late to the party, but here is what worked for me.

 

But I'm not seeing the parameter that is being created getting used, so I'm not sure the Try/Catch parameter creation is needed?

 

Sorry, I think I asked the wrong question above. The parameter is being used, but only as a temporary placeholder, it's not getting populated with the charge number. Is that the intent?

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

iLogicVb.UpdateWhenDone = True
'check For Parameter and create If Not found
Try
	'get parameter value (just to see if it exists)
	oTest = Parameter("chargeNumbers")
Catch
	' Get the active document. Assumes a part document is active.
	Dim partDoc As PartDocument
	partDoc = ThisApplication.ActiveDocument
	' Get the UserParameters collection
	Dim userParams As UserParameters
	userParams = partDoc.ComponentDefinition.Parameters.UserParameters
	'create the parameter
	oParam = userParams.AddByValue("chargeNumbers", "g-job", UnitsTypeEnum.kTextUnits)
End Try

'Set the list
MultiValue.List("chargeNumbers") =  GoExcel.CellValues("C:\TEMP\chargeNumbers.xlsx", "Sheet1", "A1", "A10")
'Get user input and set number

iProperties.Value("Project", "Project") = _
InputListBox("Choose a number.", MultiValue.List("chargeNumbers"), _
MultiValue.List("chargeNumbers").Item(0), "iLogic", "List of charge numbers:")

 

EESignature

Message 5 of 7

Curtis_Waguespack
Consultant
Consultant

This version uses the custom parameter to store the charge number:

 

Try
	'get parameter value (just to see if it exists)
	oTest = Parameter("chargeNumbers")
Catch
	' Get the active document. Assumes a part document is active.
	Dim partDoc As PartDocument
	partDoc = ThisApplication.ActiveDocument
	' Get the UserParameters collection
	Dim userParams As UserParameters
	userParams = partDoc.ComponentDefinition.Parameters.UserParameters
	'create the parameter
	oParam = userParams.AddByValue("chargeNumbers", "g-job", UnitsTypeEnum.kTextUnits)
End Try

'Set the list
MultiValue.List("chargeNumbers") =  GoExcel.CellValues("C:\TEMP\chargeNumbers.xlsx", "Sheet1", "A1", "A10")
'Get user input and set number

chargeNumbers = InputListBox("Choose a number.", MultiValue.List("chargeNumbers"), _
chargeNumbers, "iLogic", "List of charge numbers:")

EESignature

0 Likes
Message 6 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

This might be the cleanest way to do this:

 

 

Dim MyArrayList As New ArrayList
MyArrayList = GoExcel.CellValues("C:\TEMP\chargeNumbers.xlsx", "Sheet1", "A1", "A10")

'check for blank iproperty
If iProperties.Value("Project", "Project") = "" Then
	Goto _GetUserInput
End If

'get current value of iproperty 
For i= 0 To MyArrayList.Count-1
	If MyArrayList.Item(i) = iProperties.Value("Project", "Project")  Then
		iCurrent = i
		Exit For
	Else
		iCurrent = 0
	End If
Next

_GetUserInput:

iProperties.Value("Project", "Project") = _
InputListBox("Choose a number.", MyArrayList, _
MyArrayList.Item(iCurrent), "iLogic", "List of charge numbers:")

EESignature

Message 7 of 7

Anonymous
Not applicable

Hi Curtis,

You're moving too fast, I can't write my reply!

 

First, thanks very much for posting.  My intentions are to 1) set the charge number multi-value parameter correctly for the file, 2) apply that charge number to the iProperties "project" attribute, and 3) use that charge number from the parameter to generate some other values later on. 

 

The code from your nearly-last post still gives me the error I mentioned earlier, which is a bummer.  I'm trying to do some of the work but I can't keep up with you!

Cheers,

AK

 

edits:

  • come to think of it, I really don't need to make a multi-valued parameter if I can just have access to the 'charge number' value.  That's cleaner and I don't really need a record of all my charge numbers in every file.
  • Your latest code is terrific!  Thank you very much
0 Likes