ChamferNote.UnitAttributes Property fails to permit get/set of any members

ChamferNote.UnitAttributes Property fails to permit get/set of any members

prhoads3W8KL
Contributor Contributor
459 Views
8 Replies
Message 1 of 9

ChamferNote.UnitAttributes Property fails to permit get/set of any members

prhoads3W8KL
Contributor
Contributor

Hello, trying to use the UnitAttributes property provided under the ChamferNote object, but any attempt to set/get any of it's members returns "Object variable or With block variable not set" error. Using a With block to get/set any/all of the members also fails.  See below script, this is a basic test script that simply tries to read one of the members. Can anyone tell me what I am doing wrong?

 

Sub Test_Chamfernote_UnitAttributes()

Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oDimCham As ChamferNote

For Each oSheet In oDrawingDoc.Sheets
For Each oDimCham In oSheet.DrawingNotes.ChamferNotes

 

Debug.Print oDimCham.UnitAttributes.PrimaryLinearUnits

 

Next

Next

End Sub

0 Likes
460 Views
8 Replies
Replies (8)
Message 2 of 9

nmunro
Collaborator
Collaborator

You would think that would be a logical place to find that type of information. Unfortunately overrides to the generated chamfer note are contained only in the FormattedChamferNote property. You will have to use some string manipulation to adjust things such as Distance1 Precision='3' or toleranaces.

 

<Distance1 Precision='2' AlternatePrecision='2' UpperTolerance='0.000000' LowerTolerance='0.000000' ToleranceType='kSymmetricTolerance' TolerancePrecision='2' ToleranceAlternatePrecision='2'></Distance1> X <Angle Precision='2' UpperTolerance='0.000000' LowerTolerance='0.000000' ToleranceType='kSymmetricTolerance' TolerancePrecision='2'></Angle> Chamfer

 

        


https://c3mcad.com

0 Likes
Message 3 of 9

prhoads3W8KL
Contributor
Contributor

Thanks for the quick response.  I did see the FormattedChamferNote as the only way, although this method has it's limitations:

1. You can't determine if the precision that is being used by the chamfernote is coming from the global setting or the override, and the values provided in the FormattedChamferNote strictly come from the override. This means the Precision='2' may or may not be the precision used by the chamfernote

2. While you can change the override value using the FormattedChamferNote, and any change to these values will trigger setting the chamfernote to use override settings if they were global before, you can not reset the chamfernote to use the global setting.  This behavior applies to both the main precision and tolerance settings, if you make any change to the values, it will trigger the tolerance to use override, but there is no way to switch back to global. There is actually a parameter that will appear in the FormattedChamferNote called "SetTolerance" and will be set to "False" if global tolerance is used (the same flag is not provided for main precision), and "True" if override tolerance is used, but setting this value to "False" in an attempt to reset the tolerance to global has no effect.

3. While I have not seen this behavior in ChamferNote , I have seen a problem in HolethreadNote, where FormattedholethreadNote returns XML with substrings removed, particularly around the SetTolerance='False' returning "False'" (note only one ' around "False" and no "SetTolerance=") in the FormattedholethreadNote, causing the re-setting of this raw value back to the variable to fail (there is a technical support issue reported on this here). No telling if this issue could also be present in FormattedChamferNote under the right conditions.

 

Still, I ponder as to why Autodesk would provide "UnitAttributes" and make it unusable, just an orphaned function? left incomplete? I would like Autodesk to tell me what their intention was with UnitAttributes rather than let them off the hook and move on to use a band-aid work around like FormattedChamferNote.

0 Likes
Message 4 of 9

nmunro
Collaborator
Collaborator

All annotations in a drawing get their formatting from the active dimension style. Have a look at the DimensionStyle property of the chamfer note object and you will be able to extract all the default format settings for comparison with the values in the FormattedChamferNote property.

        


https://c3mcad.com

0 Likes
Message 5 of 9

prhoads3W8KL
Contributor
Contributor

The properties available under dimensionstyle still do not provide a means to identify if the specific chamfernote is driven by global or override precision. Furthermore, I can set global to the chamfer note while the style still says override, and vice versa, so apparently there are two setting for global/override, one for the style and one specific to the chamfernote. Like other dimensions, there appears to be a set of precision/tolerance details that are fed into the dimension during first creation, but thereafter any setting changes that are made to the precision/tolerance in the chamfernote edit window become local to that one chamfernote and are not effecting the style. This makes sense because if it were updating the style, it would have an effect on all of the other chamfernotes using that style.  Therefore we come back to needing precision/tolerance details specific to each chamfernote, which can not be found under dimensionstyles. These local details are provided for holethreadnotes, and other dimensions, but with the chamfernote, there is only this mysterious UnitAttributes property which appears to be the information one would need, but then it does not seem to work.  Circling all the way back to the original question, if anyone knows how to get this UnitAttributes to actually work, maybe I am missing the proper syntax or something. Or maybe someone can confirm, yes, this is a bug and does not work.

0 Likes
Message 6 of 9

nmunro
Collaborator
Collaborator

All the information is there but it takes a bit of work.

 

The DimensionStyle property holds all the information about the LOCAL dimension style applied to the annotation (the chamfer note). This style is saved with the document so even if it is modified, it will be the style referenced by all annotations that use that style

 

Modifications to a chamfer note (also applies to other annotations) are stored with the annotation itself. In the case of a standard Inventor chamfer note, this is done in the UI by editing the chamfer note, clicking the Precision and Tolerance button and then unchecking the Use Global Precision checkbox. The user can then override the precision and tolerance values for the included parameters, Distance1 and Angle for the standard chamfer note.

 

To do this programmatically you just need to change the FormattedChamferNote property to include the specific overrides. As an example, the following two values for a standard chamfer note and a user overridden (via the UI) chamfer note for the same annotation show the differences where the precision of the Distance1 value has been changed from 2 to 3 decimal places, and a symmetrical tolerance of .005"  (0.0127cm) was added.

 

ORIGINAL CH NOTE
<Distance1 Precision='2' AlternatePrecision='2' UpperTolerance='0.000000' LowerTolerance='0.000000' ToleranceType='kSymmetricTolerance' TolerancePrecision='2' ToleranceAlternatePrecision='2'></Distance1> X <Angle Precision='2' UpperTolerance='0.000000' LowerTolerance='0.000000' ToleranceType='kSymmetricTolerance' TolerancePrecision='2'></Angle> Chamfer

CH NOTE FOR MODIFIED CHAMFER NOTE
<Distance1 Precision='3' AlternatePrecision='2' UpperTolerance='0.012700' LowerTolerance='0.000000' ToleranceType='kSymmetricTolerance' TolerancePrecision='3' ToleranceAlternatePrecision='2'></Distance1> X <Angle Precision='2' UpperTolerance='0.000000' LowerTolerance='0.000000' ToleranceType='kSymmetricTolerance' TolerancePrecision='2'></Angle> Chamfer

The DimensionStyle.LinearPrecison property has a value of LinearPrecionEnum.kTwoDecimalPlacesLinearPrecision, which represents two decimal places. This information is read-only and does not change when the user overrides the chamfer note. Styles can recognize these enumerated values but the FormattedChamferNote requires the precision to be character(s) that represent the numerical value (e.g. 3). You would have to convert the enumerated value in the Dimension Style to a numeric value to compare it to the current numerical value (from the string) in the FormattedChamferNote.

 

If your code needs to do this on a regular basis, consider writing smaller functions that do singular tasks, such as

Function IsChamferPrecisionOverriden(chNote as ChamferNote) As Boolean. You would compare the appropriate dim style property(ies) and value(s) extracted from the FormattedChamferNote to see if the are the same, and return the appropriate true or false value. 

 

So it will take some work but that is often the case. There are plenty of cases where the Inventor API does not quite work the way it may be implied in the help file. Best of luck with this.

 

 

 

        


https://c3mcad.com

0 Likes
Message 7 of 9

prhoads3W8KL
Contributor
Contributor

I am well aware of the FormattedChamferNote, but as stated before, this is still missing the detail of whether or not the precision in the chamfernote is driven by the global setting or the overrides.  To be reliable, I need to know where the precision is derived from in order to determine the as-displayed precision, when the global and override precisions are different.  

 

Let me provide an example to illustrate.  I have a style with precision 3 decimal places and I make a chamfer note with this style.  The chamfernote displays with 3 decimal places.  Now, if I query FormattedChamferNote, it says Precision='2'. Why does it fail to read the precision as displayed? Because it is always reading the precision of the override, whether used or not.  For example, if I go ahead and uncheck "Use Global Precision" and change the override to 4 decimal places, then query FormattedChamferNote, it returns Precision='4', but if I recheck "Use Global Precision" (which successfully causes the displayed precision to revert to 3 decimal places), and then query FormattedChamferNote again, it still returns Precision='4'. So I have no programmatic way of knowing what is the current displayed precision. It could be 4 or 3, there is no way to know without looking at the displayed precision.

 

So DimensionStyle.LinearPrecison returns 3 and FormattedChamferNote returns 4, but which one is displayed? No way to tell.

0 Likes
Message 8 of 9

nmunro
Collaborator
Collaborator

OK, I see that the formatted note is not behaving as expected either, it doesn't reset the precision value back to the dimension style precision when you re-check Use Global Precision.  It looks like they have not implemented the UnitAttributes property for any of the note types it is supposed to apply to other than the GeneralNote type. That seems odd as that note type doesn't often include parameter values. Bend and punch notes also are missing this implementation.

 

It looks like the Text property of the ChamferNote object shows the actual text as it appears on the sheet, so you could use that to do the comparison for precision. A bit more work than the previous comparison but still possible.  Unless someone else chimes in with a solution, I would suggest you put in a defect report on the lack of UnitAttributes implementation. 

        


https://c3mcad.com

0 Likes
Message 9 of 9

prhoads3W8KL
Contributor
Contributor

You are arriving at the same conclusion that I did, that the text property may be the only reliable option. Only problem with the text property is that it returns "\Q" for stacked dual dimensions (so multi-line chamfers), which prevents interrogating the dimension precision.

 

It is strange to me that they clearly intended to provide "UnitAttributes" but then left it broken.

0 Likes