Standard channel part

Standard channel part

corey_danielson
Advocate Advocate
2,112 Views
19 Replies
Message 1 of 20

Standard channel part

corey_danielson
Advocate
Advocate

Been working with inventor for about 6 months, So much to learn. Here I am trying to set up channels. I have a form set up and everything works just right. Except for the description in iproperties project tab. I would like that to update to the channel Description X length (3 X 3.50# X 36" LONG)  So I am combining 2 parameters. (Or I should say trying to.)

 

 

CStr(DESCRIPTION & LENGTH)

If DESCRIPTION = "CHANNEL 3 X 3.50#" Then
	CHANNELSIZE = 3.0 
	FLANGE = 1.38
	FLANGETHICKNESS = .246
	WEB = .135
	UPPERFLANGE = .285
	PartNumber = "DESCRIPTION"  & LENGTH

 I do have an End If after this, then the next sized channel. 

0 Likes
Replies (19)
Message 2 of 20

WCrihfield
Mentor
Mentor
Accepted solution

Hi @corey_danielson.  One strategy I often use when I want to automate the Title &/or Description (or other) iProperty's value to include parameter based information is the following steps:

  • Open the Parameters dialog, find (and rename, if needed) the parameters whose values you want to include, then click in the checkbox on the Export Parameter column, to put a checkmark in that checkbox (see image below).
    • This does multiple things, but importantly here, it will automatically create a custom iProperty with the same exact name as this parameter, and with the same value, and it will keep that custom iProperty accurate to this parameter (but not the other way around).
  • After you do that, then right-click on that parameter's row in that dialog, and choose the "Custom Property Forma.." option, as seen in the image below.
    • This will open a small pop-up dialog, as seen in an image below, where you can customize the format of that custom iProperty's value.
    • You can change the value's Type between Text or Number.
    • You can change the Units, if needed.
    • You can change the Precision, if needed (can be used to round value).
    • If you chose Text type value:
      • If you chose 'imperial' length Units, such as Inches or Feet, you can then change the Format between Decimal and Fraction.
      • You can control whether the units string is included
      • If Decimal Format is chosen, then you can control whether to include leading, or trailing zeros.
  • You can also apply these formatting changes to other similar parameters that have been marked for export.

WCrihfield_0-1726145462297.png

WCrihfield_1-1726145571019.png

WCrihfield_2-1726146148757.png

Then, once that step is done, you can now use those custom iProperties within the 'Expression' of other iProperties.

For a quick example, when I open the iProperties dialog, to the Summary tab, and click within the Title iProperty text field, delete all existing text within it, then type in "=<ai>" (without the quotes around it), then hit the enter key on my keyboard, it will evaluate that expression, which is pointing to that custom iProperty we just made, and it will show the 'formatted' value of that iProperty in that iProperty field.  We can also combine multiple of those <name> fields within the same overall 'expression', to make complex values which include multiple referenced properties.

WCrihfield_3-1726147238346.png

WCrihfield_4-1726147259492.png

 

 

 

 

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 20

corey_danielson
Advocate
Advocate
Accepted solution

Thank you for the info, what I need to do is get the channel info (DESCRIPTION1) and the (LENGTH) into the description under the project tab so it will appear in the parts list correctly every time.

 

Parameter1 image - DESCRIPTION1 is the current channel size

                                    LENGTH is the current length

 

Those 2 parameters update when I change the form. You can see I do not have the option to export parameter DESCRIPTION1.

 

Parameter2 image   I was trying to get the Part Number to fill in with the rule.

 

Parameter3 image I was trying to get the Part Number (CHANNEL 5 X 9.0# X 48" LONG)   Thats how I hope to see it in the parts list every time. (Open the standard channel, save it as your part number for your assembly, then adjust to the size you need by using the form (parameter4)

0 Likes
Message 4 of 20

corey_danielson
Advocate
Advocate
Accepted solution

the fourth one

0 Likes
Message 5 of 20

WCrihfield
Mentor
Mentor
Accepted solution

Hi @corey_danielson.  Since we are dealing with different unit types of parameters, and you are using an older version of Inventor that does not allow you to export text or Boolean type parameters, then we will have to do this a little different than what I originally had in mind.  I would probably just get rid of the Parameter named "PartNumber", because we can bypass that and just write the 'result' String (text) directly to those two iProperties (Part Number & Description).  Below is an attempt at modifying that section of your iLogic rule a bit, but it is complicated to do so accurately without being familiar with your local document and the whole rule's code.

 

I could recommend getting the value of that "DESCRIPTION1" Parameter to a local (defined within the rule) String type variable, as its value...to avoid any Type casting &/or Object Type confusion.  Then, I would create two more String type variables...one for the Part Number, and one for the Description.  These will be used to hold onto the values that you will want to write directly to your iProperties.

 

Then, within each of your different blocks of code that is checking things and changing values, set the values of both of those variables, near the end of each block of code.  Then, after all checking & changing, use those two variables to set the values of your iProperties.

The code below is just a loosely edited version of the code you posted above, but it is not for direct cut/paste use...just suggestions.

Dim sDescription1 As String = DESCRIPTION1
Dim sLength As String = CStr(LENGTH)
Dim sPartNumber As String = ""
Dim sDescription As String = ""
If sDescription1 = "CHANNEL 3 X 3.50#" Then
	CHANNELSIZE = 3.0 
	FLANGE = 1.38
	FLANGETHICKNESS = .246
	Web = .135
	UPPERFLANGE = .285
	
	'set values to our local String type variables
	sPartNumber = sDescription1 & " X " & sLength
	sDescription = sPartNumber
ElseIf
	'other possible similar blocks of code
Else
	
End If
	
	'at some point near the end of your code,
	'use these two lines to write those values to the actual iProperties directly
	iProperties.Value("Project", "Part Number") = sPartNumber
	iProperties.Value("Project", "Description") = sDescription

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 20

corey_danielson
Advocate
Advocate
Accepted solution

I will try this out, thank you very much for the info (I am using inventor 2022) I will let you know how this worked when I get done. Thanks again!

0 Likes
Message 7 of 20

corey_danielson
Advocate
Advocate
Accepted solution

Sorry if I am misunderstanding you and thank you for being so descriptive. I also commented out line 3, the image shows the error message I get. I included a word document with the entire code on there. Any suggestions? You seem to know much more about this than me, so any help is greatly appreciated

 

I do notice in the error message, the description looks correct

0 Likes
Message 8 of 20

WCrihfield
Mentor
Mentor
Accepted solution

The error message is fairly clear this time, but does not say which line of code it happened at.  Based on what it was trying to do, and the String type data it showed, I can tell where it came from though.

  • First of all...never name your 'local variables' (variables that only exist within the rule) the exact same as any Parameter's name, and never exactly the same as any 'keywords' used by the code system (Inventor API & iLogic API).  Both spelling and capitalization are important.
  • Next, when combining multiple objects together to create a single String type value:
    • Always use the '&' character, which you are already doing.  We can also use the + character, but that one often leads to problems, because it is also used by math operations.
  • All objects between the '&' characters should already be String type values, or should be double quoted text ("text"), but the following line of code:  [Part Number = DESCRIPTION1 & " X " & LENGTH] does not follow that pattern, because 'LENGTH' is a Double data type value, which it will not automatically convert to String for you, and is causing this error.
  • That is why I created a separate variable at the top of my example code named "sLength", where the lowercase "s" indicates that this variable represents a String type value, and I was converting the Double value of the parameter named "LENGTH" to a String type value, to set as the value of that variable.  Then I was using that variable, not the blue parameter, when combining information into one String for Part Number & Description.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 20

corey_danielson
Advocate
Advocate
Accepted solution

Still working on this, the error code will come up for which ever channel I pick from my form. It changes if I pick a different channel.

0 Likes
Message 10 of 20

WCrihfield
Mentor
Mentor
Accepted solution

Hi @corey_danielson.  I think this is because you have that same exact, problematic line of code in every single variation block of code.

WCrihfield_0-1726163582956.png

This will need to be fixed (where 'LENGTH' is not being used directly there, because it represents a Double data type value of a Parameter directly).  Then, every place that line of code is in your whole rule, will need to be replaced by the fixed line of code.  Or, remove it from all those locations, and just put that (fixed) line of code in one place...after all your variations, because it only needs to happen once.

If you can not understand how to use the local variable idea I tried to explain earlier, then maybe the following can be used instead:

PartNumber = DESCRIPTION1 & " X " & CStr(LENGTH)

...or maybe something like this:

PartNumber = DESCRIPTION1 & " X " & (LENGTH).ToString

 ...because 'LENGTH' must be converted from a Double to a String, one way or another, before you can put together with other String values within one String.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 11 of 20

corey_danielson
Advocate
Advocate
Accepted solution

thank you for all your help, I have much to learn. I will look through these notes and see what is needed to fix this.

I do appreciate all your help.

0 Likes
Message 12 of 20

corey_danielson
Advocate
Advocate
Accepted solution
This is the last block of text, my only error I have is Error on line 261 : End of statement expected.
Can you tell me what you see here, I think everything else works

If
DESCRIPTION1 = "CHANNEL 12 X 30.0#" Then CHANNELSIZE = 12.0 FLANGE = 3.17 FLANGETHICKNESS = .501 WEB = .510 UPPERFLANGE = .563 PartNumber = DESCRIPTION1 & " X " & CStr(LENGTH) End If If iProperties.Value("Project", "Part Number") = sPartNumber End If If iProperties.Value("Project", "Description") "sPart Number" "X" "sDESCRIPTION1" (this is line 261) End If

 

0 Likes
Message 13 of 20

WCrihfield
Mentor
Mentor
Accepted solution

OK.  Actually the last 4 lines of code there look suspicious.

In the fourth and third from last lines there, you are using an If...End If statement, but there is no 'Then' keyword used at the end of the If line...which indicates to me that you are just trying to 'set' the value of that iProperty, and not 'checking' the value of that iProperty.

 

If your intention there is to 'set' its value, then:

  • remove the 'If' from the start of that line of code, then also delete the 'End If' from the next line.

If your intention there was to 'check' the value, then:

  • After the "= sPartNumber" portion should be the keyword "Then" after a single space
  • There would be another line of code (or multiple more lines) between the 'If' and the 'End If', where you do something, depending on if the value matched what you are comparing it to.

Then again, with the last two lines shown there, similar situation, but worse.

The next to last line starts with 'If', but I do not see anything later within that line of code where you are checking anything, such as if the value equals something, to see if it is True.  The last line is just 'End If', which would be OK, if there was something 'checked' within the 'If' portion in the line before that, and there was some extra code reacting to the result of that test.

 

Are you trying to 'set' the value of that iProperty there, or are you checking something there?  I can't tell.

It kind of looks like you intended to set the value of the Description iProperty, but if that is the case, then several things would have to change there.

 

If trying to 'set' the value of that iProperty, then:

  • remove 'If' from the front of that line of code
  • insert "=" symbol (unquoted) between ["Description")] and the rest that follows it
  • Include the & symbol between each of those 3 Strings you are trying to join together into one String
  • remove your comment after that point (where it says "(this is line 261)")
  • Delete the 'End If' from the last line

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 14 of 20

chris
Advisor
Advisor
Accepted solution

@corey_danielson "Current Length" is a tricky one, the problem, or I should say challenge when populating your BOM with a "Length" in the parameters is that if it's tied to a regular parameter or a user-defined parameter it has the potential to be wrong... unless the person using the template or part file is very aware of how it works and what drives the parameters. That's why I have all my "lengths" values being driven from the "extents" so regardless of whether I create a new extrusion to add or subtract, it won't affect the length, or width or height for that matter

0 Likes
Message 15 of 20

corey_danielson
Advocate
Advocate
Accepted solution

Last question, I think. My parameter "Part Number" updates flawlessly. It is tied to the channel rule. I do not have the Export option. I think if there is a way to make that visible, I may have this figured out. Can you tell me if there is a way to get the export button? I will gladly recreate the parameter if I need to get this option.  Thank you.

0 Likes
Message 16 of 20

WCrihfield
Mentor
Mentor
Accepted solution

Hi @corey_danielson.  I think it was in the 2024 version of Inventor that we finally got the ability to export text and Boolean type user parameters.  You can see this in the following online help documentation:

Parameter Enhancements (What's New in 2024) 

Keep in mind that using this export setting automatically keeps the custom iProperty it creates up to date with the parameter when the parameter changes.  However, changing the value of the custom iProperty does not change the parameter.

 

Before we had this ability, we had to create the custom iProperty ourselves, with the same name as the parameter, and with the same value as the parameter.  However, the custom iProperty we create ourselves is not automatically updated when the parameter changes.  We had to use our own custom automation methods to try to keep the custom iProperty accurate to the parameter's value.  This was usually possible by using an internal rule (saved within the document) that includes the blue, unquoted named of the parameter, so that whenever the value of that parameter changes, it will trigger that rule to run.  Then, within that rule, set the value of the custom iProperty to the value of the parameter.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 17 of 20

corey_danielson
Advocate
Advocate
Accepted solution

Thank you for all your help. I am checking with IT about 2024. You have answered all my questions.

Thanks again, If I can get 2024, that should solve my problem. (Everything in the user parameter updates like I want, with length. I am hopeful that 2024 fixes it.)

0 Likes
Message 18 of 20

corey_danielson
Advocate
Advocate
Accepted solution

Last question. How do I get the part number to show up? I wrote a separate rule to fill in the description, that seems to work correctly. I will be figuring out if I can add   " LG   behind the length, but for now I would like to see the part number populate. I created a test assembly with 4 parts saved from my start part. The parts list populated perfect for SP2, but the other items did not show a part number. You have been a huge help on this, as you can see, I have this just about to where I need. Thank you.

0 Likes
Message 19 of 20

WCrihfield
Mentor
Mentor
Accepted solution

Hi @corey_danielson.  As I showed at the end of the code I posted in Message 5 above, that was what this line of code is for:

iProperties.Value("Project", "Part Number") = sPartNumber

...when you have set the value of that 'sPartNumber' String type variable to the value you want to set as the value of your actual Part Number iProperty before that point in the code.  But that line of code should not be within an 'If...Then...End If' statement, like you were showing in Message 12, as I tried to explain in Message 13.

 

However, this will be putting a 'static' value for the Part Number (which is normal).  What I mean is, its value is not 'live' or 'linked' to anything (not linked to the parameter), so its value will not change on its own until you run your rule again that sets its value.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 20 of 20

corey_danielson
Advocate
Advocate
Accepted solution

Got it working with description and length, just the way I wanted to. Thank you for all your help, Wesley. I was going to accept solutions on everything.

0 Likes