ModelParameter to DimensionConstraint

ModelParameter to DimensionConstraint

Anonymous
Not applicable
541 Views
4 Replies
Message 1 of 5

ModelParameter to DimensionConstraint

Anonymous
Not applicable

Hi.

 

Can anyone tell me how to convert model parameters (which are actually created while constraining the sketch)  to DimensionConstraints

 

Thanks in advance,

Sundeep

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

sanjay.ramaswamy
Alumni
Alumni

There isn't an easy way to go from a parameter to the owning constraint. The brute force way is to iterate over all dimension constraints and compare the Parameter object returned by DimensionConstraint.Parameter to the object that you have.

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Sanjay,

 

Thanks for the reply,

 

The actualy scenario is the sketch is from the iFeature, so when i iterate through the DimensionsConstraints and get the parameter, it fails and this is the error:

 

 oDimensionConstraint.Parameter {"The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"} Inventor.Parameter

Here's the code i use to iterate through the iFeatures:

Dim oPartDef As PartComponentDefinition = oPartDoc.ComponentDefinitionFor Each oiFeature As iFeature In oFeatures.iFeatures

 

Dim oDimsToRetrive As ObjectCollection

oDimsToRetrive = _InventorApp.TransientObjects.CreateObjectCollection()

 

 

            For Each oiFeatSketch As Sketch In oiFeature.Sketches

                     For Each oDimensionConstraint As DimensionConstraint In oiFeatSketch.DimensionConstraints

                                   If oDimensionConstraint.Parameter.Name.ToUpper.Contains("FAB")  Then

                                           oDimsToRetrive.Add(oDimensionConstraint)

                                    End If

                      Next

           Next

Next

Thank You,

Sundeep

0 Likes
Message 4 of 5

sanjay.ramaswamy
Alumni
Alumni

That does seem to be a problem in the API. The DimensionConstraint.Parameter property fails for all constraints within an iFeature sketch. I've filed this issue in our database.

 

Unfortunately, I don't know of any workarounds. Sorry.

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

Sanjay,

Thank you for your help.

I will try to find a workaround for that and will keep you posted and please let me know in case you find any too.

 

Thanks again,

Sundeep

0 Likes