ilogic add a user parameter and set it as an iProperty

ilogic add a user parameter and set it as an iProperty

theo_karypidis
Contributor Contributor
4,344 Views
6 Replies
Message 3 of 7

ilogic add a user parameter and set it as an iProperty

theo_karypidis
Contributor
Contributor

Hello,

 

I want to create an User parameter (named "Comments") and then set it as the existing iProperty Comments from summary tab.

 

I have the following code:

SyntaxEditor Code Snippet

oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
Dim userParams As UserParameters = oMyParameter

'ADD COMMENTS
Try
 parametro = ThisApplication.ActiveDocument.ComponentDefinition.Parameters("Comments")
 Catch
   Dim newParam As UserParameter = oMyParameter.AddByValue("Comments", "", UnitsTypeEnum.kTextUnits)
End Try

 iProperties.Value("Summary", "Comments") = Comments

It checks if there is a user parameter named "Comments" and if not, it adds it with an empty text value.

The problem is, it seems to be stopping there.  It sets the empty value and it stays that way. 

 

And when I try to fill the comment property from a form, it doesn't work. It fills the user parameter but the ipropery comment stays empty.

 

The 

iProperties.Value("Summary", "Comments") = Comments

works without the rest of the code of course if the user parameter pre-exists.

What I think happens is that when I create the Comments parameter and give it an empty value it stays as empty and ignores the rest. 

Also in the form the text is already multi line. 

 

Any ideas how to solve that would be appreciated!!

0 Likes
Accepted solutions (1)
4,345 Views
6 Replies
Replies (6)
Message 1 of 7

theo_karypidis
Contributor
Contributor

Hello,

 

I want to create an User parameter (named "Comments") and then set it as the existing iProperty Comments from summary tab.

 

I have the following code:

SyntaxEditor Code Snippet

oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
Dim userParams As UserParameters = oMyParameter

'ADD COMMENTS
Try
 parametro = ThisApplication.ActiveDocument.ComponentDefinition.Parameters("Comments")
 Catch
   Dim newParam As UserParameter = oMyParameter.AddByValue("Comments", "", UnitsTypeEnum.kTextUnits)
End Try

 iProperties.Value("Summary", "Comments") = Comments

It checks if there is a user parameter named "Comments" and if not, it adds it with an empty text value.

The problem is, it seems to be stopping there.  It sets the empty value and it stays that way.  And when I try to fill the comment property from a form it doesn't work.

 

Any ideas would be appreciated!!

0 Likes
Message 2 of 7

philip1009
Advisor
Advisor

First I'll let you know that iLogic and similar questions are better suited for the Inventor Customization forum.

 

When you add the parameter to the form, you have to change the behavior to Multi-Line Text Box to match the multi-line format of the comments iProperty:

text_edited.jpg

0 Likes
Message 4 of 7

theo_karypidis
Contributor
Contributor

thank you. I have posted a better explanation to the Customization forum 

I have already done what you said that's not the problem

0 Likes
Message 5 of 7

philip1009
Advisor
Advisor

I think the main problem is that when the parameter is newly created, there's no way to convert it to a multi-line text parameter without going into the form editor, which isn't exposed in the API as far as I can tell, so I think we're stuck on this one until Autodesk updates it for the future.  Make a post in the Inventor Ideas forum to help make them aware of it.

 

For now, my recommendation is to update your templates to have that form and update rule.  After the process of creating the text parameter, putting it in a form, turning the behavior to multi-line, then making the rule that will auto-update when set in the right Event Triggers or by putting in the rule as a button on the form it will work, I have it working on my end just fine.

0 Likes
Message 6 of 7

GeorgK
Advisor
Advisor
Accepted solution
iProperties.Value("Custom", "Comments") = "Test1234"
0 Likes
Message 7 of 7

theo_karypidis
Contributor
Contributor

You mean to use the comment from a custom property instead right?  Then my titleblock can be set to read that custom property.. Can I also do it so it fills the existing iProperty Summary\Comments?

0 Likes