API code to add parenthesis to a dimension?

Discussion in 'SolidWorks' started by SW Monkey, Jun 10, 2005.

  1. SW Monkey

    SW Monkey Guest

    I couldnt find this in API help. Im trying to create a button that
    will change a selected dimension properties to include parenthesis.

    Anyone know the code?
     
    SW Monkey, Jun 10, 2005
    #1
  2. SW Monkey

    vizach Guest

    Try this under Annotation object, Dispaly Dimensions

    DisplayDimension::ShowParenthesis
    Description

    This property gets or sets whether the dimension is displayed with
    parenthesis around the text.

    Syntax (OLE Automation)
    show = DisplayDimension.ShowParenthesis (VB Get property)
    DisplayDimension.ShowParenthesis= show (VB Set property)

    Vizach
     
    vizach, Jun 10, 2005
    #2
  3. SW Monkey

    SW Monkey Guest

    I cant seem to get this to work.

    a. I want to click on a pre existing dimension, and click a button to
    add parenthesis

    and

    b. Click on a button to create a dimension with parenthesis.

    This will allow me to change existing dimensions, and add new ones.

    I figure the DisplayDimension.ShowParenthesis=show would be true for A,
    but I get a error when running the code.
     
    SW Monkey, Jun 13, 2005
    #3
  4. SW Monkey

    SWX-VAR-JP Guest

    Dim swApp As Object
    Dim Part As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim FeatureData As Object
    Dim Feature As Object
    Dim Component As Object
    Dim swDispDim As SldWorks.DisplayDimension
    Dim swDraw As SldWorks.DrawingDoc
    Dim swAnn As SldWorks.Annotation
    Dim swSelMgr As SldWorks.SelectionMgr

    Sub main()

    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    Set swDraw = Part
    Set swSelMgr = Part.SelectionManager
    Set swDispDim = swSelMgr.GetSelectedObject5(1)

    Set Dimension = swDispDim.GetDimension

    swDispDim.ShowParenthesis = True

    Part.ClearSelection2 True
    End Sub

    This will set the dimension display to parenthesis on. You will need
    to place an error trap if someone does not select anything. The second
    part about placing a dimension is easy. No need to discuss here.

    Good Luck!
     
    SWX-VAR-JP, Jun 13, 2005
    #4
  5. SW Monkey

    SW Monkey Guest

    That code works great. Im still learning how to write code. Im trying
    the second macro, that will create a dimension with parenthesis, but im
    having some trouble.

    I recorded a macro when creating a dimension, but it will only run on a
    preselected edge. What Im trying to get is a "Smart Dimension" that
    has parenthesis automatically.
     
    SW Monkey, Jun 13, 2005
    #5
  6. SW Monkey

    SWX-VAR-JP Guest

    Do you want all your dimensions to have parenthesis, or just specific
    ones?
     
    SWX-VAR-JP, Jun 14, 2005
    #6
  7. SW Monkey

    SW Monkey Guest

    Just specific ones. The macro above works great for changing existing
    dimensions. We changed our standards to make specific dimensions
    referenced, so as we bring up old drawings, we have to update those
    dimensions. That macro will help with that. The other macro will help
    when creating new dimensions that need parenthesis. I know you can set
    your template to set dimensions as referenced automatically, but thats
    not what we want.
     
    SW Monkey, Jun 14, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.