×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

DisplayDimension::SetPrecision

DisplayDimension::SetPrecision

DisplayDimension::SetPrecision

(OP)
I am currently using SW2001.  I am a new user to VB and API programming.
Would someone be able to supply me with an example macro that uses retval=DisplayDimension.SetPrecision(useDoc,primary,alternate,primaryTol,alternateTol) successfully.  I keep getting the message runtime error 438, Object doesnt support this property or method.

Thanks
Andre

RE: DisplayDimension::SetPrecision

Could you post some more of your code? How are you obtaining the DisplayDimension object?

There is a FAQ for removing dangling entities that illustrates how to obtain the object by traversing through all of the display dimensions in the drawing.

Can you also explain more of what you are doing? For example, are you traversing through all of the display dimensions or is the user selecting a single dimension for updating?

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: DisplayDimension::SetPrecision

(OP)
The user must select a single dimension for updating.  This part works fine.
The problem is that I can not set the tolerance precision.  The dimension precision is set by EditDimensionProperties2, but this does not set the tolerance precision.

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim theDimen As Object

Dim Component As Object


Sub main()

Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc
    Set model = Part
    
    
    Set SelMgr = model.SelectionManager()  ' Get the selection manager class
    If (SelMgr.GetSelectedObjectCount <> 0) Then   ' If user has selected something
        Set selObj = SelMgr.GetSelectedObject2(1)   ' Get the first item in the selection list
        selObjName = selObj.FullName ' Get the name of the selected component
        messageString = "Member name is " + selObjName
        swApp.SendMsgToUser messageString  ' Display to the user
        Part.SelectByID selObjName, "DIMENSION", 0, 0, 0
        HoleUpperLimit = 2.5
        HoleLowerLimit = 1.5
        MaxTolerance = HoleUpperLimit * 0.0000254
        MinTolerance = HoleLowerLimit * 0.0000254
        Part.EditDimensionProperties2 2, MaxTolerance, MinTolerance, "", "", 0, 4, 1, 1, 11, 11, "", "", 1, "", "", 0
        model.GraphicsRedraw2
        Set theDimen = Part.Parameter(selObjName)
        theValue = theDimen.Value
    End If

    retval = theDimen.setPrecision(0, 4, 2, 4, 2) ' It doesn't seem to recognize SetPrecision

End Sub

RE: DisplayDimension::SetPrecision

LeBlanc:

A few things to note.

There is a difference between a dimension and a display dimension. Note that the FullName property is not available to display dimensions. This should indicate that the GetSelectedObject2 returned a dimension rather than a display dimension.

You should also use the GetSelectedObject3() method in 2001 since GetSelectedObject2() has been marked obsolete.

All that said, here is some code that should do what you want.

Option Explicit

Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim dwgDim As Object
Dim dispDim As Object
Dim sDimName As String

Sub Main()
    Dim HoleUpperLimit As Single, HoleLowerLimit As Single
    Dim MaxTolerance As Single, MinTolerance As Single
    Dim retval
    
    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc
    Set SelMgr = Part.SelectionManager()
    
    If (SelMgr.GetSelectedObjectCount <> 0) Then
        'Get the display dimension
        Set dispDim = SelMgr.GetSelectedObject3(1)
        retval = dispDim.SetPrecision(False, 4, 2, 4, 2)
        'Get the dimension
        Set dwgDim = dispDim.GetDimension
        'Modify the dimension
        sDimName = dwgDim.FullName
        Part.SelectByID sDimName, "DIMENSION", 0, 0, 0
        HoleUpperLimit = 2.5
        HoleLowerLimit = 1.5
        MaxTolerance = HoleUpperLimit * 0.0000254
        MinTolerance = HoleLowerLimit * 0.0000254
        Part.EditDimensionProperties2 2, MaxTolerance, MinTolerance, "", "", 0, 4, 1, 1, 11, 11, "", "", 1, "", "", 0
        Part.GraphicsRedraw2
    End If
    
    Set dwgDim = Nothing
    Set dispDim = Nothing
    Set SelMgr = Nothing
    Set Part = Nothing
    Set swApp = Nothing
End Sub

Hope this helps!

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: DisplayDimension::SetPrecision

(OP)
Many thanks, this is exactly what I require.
I used GetSelectedObject2 knowing it was obsolete only because my code would not run using the new GetSelectedObject3.  Any ideas why this might be so.

RE: DisplayDimension::SetPrecision

You're welcome.

The GetSelectedObject2 method returns a Dimension object and GetSelectedObject3 returns a DisplayDimension object.

When you access the FullName property using GSO3, you will get an error because the FullName property is not available in the DisplayDimension object.

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources