Use Document's Units Code

I have a part fully defined and modeled in SolidWorks Office 2005. The Document Properties -> Units is set for a 3 place decimal. There are 3
reference dimensions that have been put on the part manually.
RD1@Annotations RD2@Annotations RD3@Annotations
I am trying to write a macro that will select these dimension, go into more properties, and then say "do not use document units", and set it to fraction rounded to the 16th.
I tried to use SolidWorks and record the macro myself, but it will not record correctly. It only records the code used to select these dimension. It will not show how to only change these dimensions to a fraction.
I have went through SolidWorks API helo, and came up empty handed. I am sure this something really simple, but I can't find it. Could someone please give me the lines of code that will change these dimensions that way I need them, or at least point me in the right direction.
Thanks
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
The below macro will change all the *preselected* dimensions to 1/16th fractional.
Ken
'****************************************************************************** ' Fractional.swb '****************************************************************************** Dim swApp As Object Dim swModel As Object Dim swSelMgr As Object Dim selCount As Integer Dim selType As Integer Dim retval As Variant Dim CurrentSelDimension As Object Dim boolstatus As Boolean Dim useDoc, roundToFraction As String Dim uType, fractBase, fractDenom As Long Dim i As Integer
Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc
If swModel.GetUserPreferenceIntegerValue(swUnitsLinear) <> swINCHES Then boolstatus = MsgBox("Program only works for files with INCH Primary" & Chr(13) & _ "Units in the Doument Settings." & Chr(13) & _ "Ending routine.", vbExclamation) End End If
useDoc = False 'TRUE=Use the document settings for units uType = swINCHES 'Set to Inches fractBase = swFRACTION 'Set to Fractions fractDenom = 16 'Denominator Base unit roundToFraction = True 'TRUE rounds values to the nearest fraction, FALSE displays fractions only if the values are exact
Set swSelMgr = swModel.SelectionManager() selCount = swSelMgr.GetSelectedObjectCount()
If (selCount > 0) Then For i = 1 To selCount selType = swSelMgr.GetSelectedObjectType2(i) If (selType = swSelDIMENSIONS) Then Set CurrentSelDimension = swSelMgr.GetSelectedObject3(i) CurrentSelDimension.SetDual True CurrentSelDimension.SetUnits useDoc, uType, fractBase, fractDenom, roundToFraction End If Next End If
swModel.ClearSelection2 True swModel.GraphicsRedraw2 End Sub
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
thanks ken - the code you gave me worked like a charm
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.