Automatically export (and give custom property format) a specific parameter?

Automatically export (and give custom property format) a specific parameter?

lars.boijens
Contributor Contributor
337 Views
4 Replies
Message 1 of 5

Automatically export (and give custom property format) a specific parameter?

lars.boijens
Contributor
Contributor

Hi all!

 

We design parts often made out of plates, so we have a "Plate.ipt" template setup for a plate design, which will automatically export the thickness ("th" parameter) of the plate to an iproperty. So for instance, the "description" iproperty is set up to show the property "=PLATE thickness=<th>. which in the parts list will show as "PLATE thickness=10, for example.

 

Now, sometimes a designer forgets to start with the standard.ipt template, instead of using the Plate.ipt template. 

In this case the thickness "th" parameter needs to be appointed to the correct parameter, and it needs to be export with the correct property format. this requires an additional number of mouse clicks in relevant each part 😉

 

My question is if I can make an ilogic (or vba code) that will autmatically exports the parameter "th"  with the correct property format if it exists in an .ipt.  

This way one only has to change 1 parameter to "th" for it to appear in the description iproperty. 

 

Many thinks in advance!

Lars 

0 Likes
338 Views
4 Replies
Replies (4)
Message 2 of 5

CCarreiras
Mentor
Mentor

I think there's no way to format a parameter from iLogic, but there are other ways to achieve this. (I mean set the "custom property format" directly in the parameters chart, of course, you can do it outside with iLogic and import it to a custom parameter to use it later.

 

you can simply have an external rule, available for every model and if you open a part, instead the sheet metal template, after you convert the part to sheet metal (could be manually or also by iLogic),  run this simple external rule.

Note: this will set the "th" value as the thickness you have when you are running the rule, is not associative.

If you change the thickness, you have to re-run the rule to update "th"

 

iProperties.Value("Custom", "th") = Thickness
iProperties.Value("Project", "Description") = "Plate=" & iProperties.Value("Custom", "th")

Check if this fits for you...

There are even better ways to maintain values associatively, but also more complicated.

CCarreiras

EESignature

0 Likes
Message 3 of 5

johnsonshiue
Community Manager
Community Manager

Hi Carlos,

 

I could be wrong since I am not an API expert. But, I did find the following object in Inventor API Help.

CustomPropertyFormat Object

Here is an old thread with some iLogic rule.

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/custom-property-format-in-ilogic/td-...

 

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 4 of 5

lars.boijens
Contributor
Contributor

That ilogic rule worked, but did not what i wanted to achieve. 

 

I made a template which already contains a parameter "th". I set this parameter up, so it exported as an custom iproperty.

 

The problem is when a designer starts a new part from the stadard.ipt which does NOT contain the parameter "th". 

When the designer then writes "th" in front of the plates thickness, for instance while making an extrusion, he has to open the parameter window to click on the export checkbox AND change the custom property format to adjust its precisoin and check away the unit string box. 

 

So my question was if there was a code (vba or ilogic) to automate the parameter export. it would save some clicking for each part which is not started from the correct template.

 

So basically automate the steps shown in the added picture.

cutom prop format.jpg

 

Thank you!

 

0 Likes
Message 5 of 5

jtylerbc
Mentor
Mentor

We used to have a similar problem at my company.  Eventually he left for another job . . .

 

Setting the parameter as Exported is relatively easy in iLogic.   See example below.  Note that I'm not the greatest coder and I yanked this sample out of an old rule that seldom gets used anymore, so there may be a cleaner way this could be written.

 

Dim oParams As Parameters
oParams=ThisDoc.Document.ComponentDefinition.Parameters
Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters

oUserParams("EXAMPLE_PARAMETER").ExposedAsProperty = True

 

As far as setting the format, we struggled with that.  As I recall, we tried using the "CustomFormatProperty" that @johnsonshiue mentioned.  At the time, I believe we were able to successfully set the format in any way except for what we actually wanted (fractional feet).   I have no idea whether we were doing something incorrectly, or this simply was a limitation of the API.  If it was an issue with the API, I have no idea whether or not it has been fixed since then. 

 

I don't have an example of the format setting since we never got it to work correctly for our situation.  But to be honest, I didn't try all that hard to make it work.  I wasn't all that interested at the time in removing all the pain of picking the wrong template file, since I was trying to get him to stop doing it.