Example code for ModelToleranceFeature

Example code for ModelToleranceFeature

bguillory2
Contributor Contributor
610 Views
4 Replies
Message 1 of 5

Example code for ModelToleranceFeature

bguillory2
Contributor
Contributor

Would anyone have sample code to create new ModelToleranceFeatures and/or modify an existing ModelToleranceFeature?

 

Thanks

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

WCrihfield
Mentor
Mentor

I don't think this is possible yet.  Model Annotations only became available to manually use in the Inventor 2019 release.  Though many are usable now by code, I don't think they've made the creation of new ModelToleranceFeatures available yet.  You can find existing ones and get/set a few things for them though.  See following code.

(In my test model, Face1 had one already assigned to it, but Face2 didn't yet.)

 

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oNFaces As NamedEntities = iLogicVb.Automation.GetNamedEntities(oPDoc)
Dim oFace1 As Face = oNFaces.FindEntity("Face1")
Dim oFace2 As Face = oNFaces.FindEntity("Face2")
'Dim oMAs As ModelAnnotations = oPDef.ModelAnnotations
Dim oMTFs As ModelToleranceFeatures = oPDef.ModelToleranceFeatures
Dim oMTF As ModelToleranceFeature = oMTFs.GetToleranceFeatureFromFace(oFace1)
Dim oFaces As FaceCollection = oMTF.AllFaces
MsgBox("Faces Count = " & oFaces.Count)
oFaces.Add(oFace2) '<<<I'm not sure if this works
MsgBox("Constrained Status = " & oMTF.ConstrainedStatus.ToString)
'oMTF.ConstrainedStatus = ModelToleranceFeatureConstrainedStatusEnum.kToleranceFeatureConstrained
MsgBox("Health Status = " & oMTF.HealthStatus.ToString)
MsgBox("Name = " & oMTF.Name)
'oMTF.Name = "MTF 1"
'oMTF.Visible = False

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

bguillory2
Contributor
Contributor

Thought it may help if I offered a bit more detail on my specific use case.

 

We have for been using a .net App for a number of years that is basically a generic Family of Parts (FOP) configurator similar to iParts but with several key enhancements. Basically it supports driving a Master model design having design features to accommodate various/optional shapes required by a set of components from a table of properties to generate standalone member models. One of the primary objectives of FOP has been to generate complete member part models fully automatically without requiring any manual edits.

 

Recently our company making a push to implement MBD/GD&T using Family of Parts design techniques.

 

Main challenge in FOP with MBD  is how to define in one Master model design all the ModelToleranceFeatures needed to fully constrain all faces  for each of the shapes.

 

Initially I hope I could in the Master Model  dial up one by one each shape and add tolerance features to get all current faces constrained. Then dial up the next shape and suppress the invalid tolerance features and be able to add additional tolerance features to constrain the additional faces produced.

 

That is basically how we get all the Design Features in the Master design for optional shape/geometry. As needed we are able to suppress certain features then add new ones to produce the next shape.

 

But Inventor behavior with tolerance feature suppression is different than with design feature suppression. There does not seem to be a way to assign multiple tolerance features to a single face. Even it the tolerance feature is suppressed or invalid Inventor won’t allow you to select the referenced face again to add additional tolerance features.

 

Which led met to try looking at extracting the tolerance feature definitions for each shape as a set. Then at runtime have the FOP app apply the correct definition set to produce the reqd tolerance features for each shape.

 

Using the example code above I was able to add basic annotations. But it is still not clear if there is api support to create tolerance features. Any explanation/examples regarding tolerance feature support with code would be appreciated.

 

Also would be interested to know any details that are available on the roadmap for future development for Inventor MBD/GDT.

 

Does Autodesk have any plans to change the behavior with Tolerance Features to support some mode where they could remain in the design but somehow be “suspended or disabled” to allow subsequent  tolerance features to be assigned to same face?

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Wow!  Sounds really complicated.  Since I don't know much about MBD & GD&T at the moment, some of that went right over my head. 🙃

But here are a few folks who might know more about it, and might be able to answer the future plans question.

@MjDeck, & @chandra.shekar.g & @johnsonshiue 

Good luck.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

stevetrudeau
Alumni
Alumni

Creation of ModelToleranceFeature is not supported yet. Existing ModelToleranceFeatures can be accessed via the API for read and edit, just not creation. The plan to implement creation API is on our radar, but no definite release date is set. 

0 Likes