Use iLogic to Format Model Parameters

Use iLogic to Format Model Parameters

Anonymous
Not applicable
1,638 Views
5 Replies
Message 1 of 6

Use iLogic to Format Model Parameters

Anonymous
Not applicable

Hey,

So I've been trying to use a lot of the information contained in this post to write code that changes the format of my Model Parameters. It seems to only work for User Parameters, however. What am I missing?

 

My code looks like this:

 

SyntaxEditor Code Snippet

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
Dim oUserParam As UserParameter


For Each oUserParam In oPartDoc.ComponentDefinition.Parameters.UserParameters
    oUserParamName = oUserParam.Name
    If oUserParamName = "Thick" Then
        oUserParam.oUserParamName.ExposedAsProperty = True
        oFormat.Format = "Fractional"
        oFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
    
    End If

Next

 

I'm attempting to call up a Model Parameter, Set it to Export, and then change it's format to Fractional and its Precision to 1/16th. 

I tried changing all the "UserParameter" instances to "Model Parameter," but it didn't work.

 

Accepted solutions (2)
1,639 Views
5 Replies
Replies (5)
Message 2 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi nealon.luke,

 

Have a look at this link:

http://forums.autodesk.com/t5/inventor-customization/mark-parameters-for-export/m-p/5795709/highligh...

 

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

EESignature

Message 3 of 6

Anonymous
Not applicable

Curtis,

I'm seeing a lot of threads (including the one you posted, thanks) that discuss methods for marking a parameter for export, changing the precision, and performing many of the other functions available in the Custom Property Format window. However, I can't figure out how to change the Format from Decimal to Fraction. Can you tell me what piece of code I'm missing there?

 

Also, is there some sort of resource or library that details all of the individual functions and what they do (and what sub-functions are available under them)? I feel like many of my questions to this forum could be solved with a quick poke at a table of some sort.

 

Thanks,

  -Luke

Message 4 of 6

Anonymous
Not applicable
Accepted solution
Curtis,

It would appear that when you change the precision to 1/16 or something like that, Inventor automatically changes your format so that it is "fractional."

Below is my code, functioning perfectly now. Thanks for the help (here and in other threads).

I decided to go with a simple try loop for each of my 5 different parameters that might come up that need to be changed (Thick, Width, Length, OD, ID), and I'll just copy/paste that code for each of the parameters. Works well enough, if not the cleanest.

'[
Try
oParam = Parameter.Param("Thick")
oParam.ExposedAsProperty = True
oParam.CustomPropertyFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
Catch

End Try
']
0 Likes
Message 5 of 6

Curtis_Waguespack
Consultant
Consultant

@Anonymous wrote:

Curtis,

... I can't figure out how to change the Format from Decimal to Fraction.

 

Also, is there some sort of resource or library that details all of the individual functions and what they do (and what sub-functions are available under them)? I feel like many of my questions to this forum could be solved with a quick poke at a table of some sort.

 

Thanks,

  -Luke


Hi nealon.luke,

 

See the reference enums below for the Decimal/ Fraction question.

 

And see this image ( it might be a bit out of date, but it is pretty close) for the API resource question.

 

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

 

Where to find the Inventor API help files:

 

pic_1

 

 

 

 

CustomPropertyPrecisionEnum Enumerator

Description

Enum specifying the precision for custom property.

Methods

Name Value Description
kDegreesAnglePrecision 85522 Degrees Precision.
kEightDecimalPlacesPrecision 85513 Eight Decimal Places Precision.
kEighthsFractionalLengthPrecision 85517 Eighths Fractional Precision.
kFiveDecimalPlacesPrecision 85510 Five Decimal Places Precision.
kFourDecimalPlacesPrecision 85509 Four Decimal Places Precision.
kHalfFractionalLengthPrecision 85515 Half Fractional Precision.
kMinutesAnglePrecision 85523 Minutes Precision.
kOneDecimalPlacePrecision 85506 One Decimal Place Precision.
kOneTwentyEighthsFractionalLengthPrecision 85521 OneTwentyEighths Fractional Precision.
kQuarterFractionalLengthPrecision 85516 Quarter Fractional Precision.
kSecondsAnglePrecision 85524 Seconds Precision.
kSecondsFourDecimalPlaceAnglePrecision 85528 Seconds Four Decimal Place Precision.
kSecondsOneDecimalPlaceAnglePrecision 85525 Seconds One Decimal Place Precision.
kSecondsThreeDecimalPlaceAnglePrecision 85527 Seconds Three Decimal Place Precision.
kSecondsTwoDecimalPlaceAnglePrecision 85526 Seconds Two Decimal Place Precision.
kSevenDecimalPlacesPrecision 85512 Seven Decimal Places Precision.
kSixDecimalPlacesPrecision 85511 Six Decimal Places Precision.
kSixteenthsFractionalLengthPrecision 85518 Sixteenths Fractional Precision.
kSixtyFourthsFractionalLengthPrecision 85520 SixtyFourths Fractional Precision.
kThirtySecondsFractionalLengthPrecision 85519 ThirtySeconds Fractional Precision.
kThreeDecimalPlacesPrecision 85508 Three Decimal Places Precision.
kTwoDecimalPlacesPrecision 85507 Two Decimal Places Precision.
kZeroDecimalPlacePrecision 85505 Zero Decimal Place Precision.
kZeroFractionalLengthPrecision 85514 Zero Fractional Precision.

EESignature

Message 6 of 6

Anonymous
Not applicable

these old post really does help!!

 

this is what I was looking for...took me awhile to find it!

 

oParam.CustomPropertyFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision

 

I was assuming that Format.Format = "Fractional" would work but doesn't.