SolidWorks API to check Sheet Size

Discussion in 'SolidWorks' started by Randy, Oct 14, 2003.

  1. Randy

    Randy Guest

    I have a macro that I am using to fill titleblock information using
    custom sheet properties defined in the titleblock area. I have radio
    buttons setup to fill in tolerances for coarse, medium, or fine. The
    tolerances are different for metric or imperial. I need to be able to
    do a check to see if the drawing is metric or imperial then fill the
    appropriate tolerance. I cannot seem to get the VB code right to
    check the sheet.

    Here's a sample of what I was trying but it always fills imperial.

    If OptionButton1.Value = True Then 'Coarse selection
    'check for standard english borders
    If swDwgPaperSizes_e = swDwgPaperDsize Or swDwgPaperCsize Or
    swDwgPaperBsize Or swDwgPaperAsize Then
    retval = drawingdoc.DeleteCustomInfo("TOLERANCE1")
    retval = drawingdoc.AddCustomInfo("TOLERANCE1", "Text",
    "0.1")
    retval = drawingdoc.DeleteCustomInfo("TOLERANCE2")
    retval = drawingdoc.AddCustomInfo("TOLERANCE2", "Text",
    "0.03")
    retval = drawingdoc.DeleteCustomInfo("TOLERANCE3")
    retval = drawingdoc.AddCustomInfo("TOLERANCE3", "Text",
    "0.010")
    Else
    'assume metric borders
    retval = drawingdoc.DeleteCustomInfo("TOLERANCE1")
    retval = drawingdoc.AddCustomInfo("TOLERANCE1", "Text",
    "3.0")
    retval = drawingdoc.DeleteCustomInfo("TOLERANCE2")
    retval = drawingdoc.AddCustomInfo("TOLERANCE2", "Text",
    "1.0")
    retval = drawingdoc.DeleteCustomInfo("TOLERANCE3")
    retval = drawingdoc.AddCustomInfo("TOLERANCE3", "Text",
    "0.25")
    End If
    End If
     
    Randy, Oct 14, 2003
    #1
  2. ModelDoc2.GetUnits (1)
    is the length unit uses the enum swLengthUnit_e

    This will tell you if it is in english or metric

    If you have control of your Templates you could name the textobjects that
    contain these values instead of setting custom props. You can then search
    for the objects by name and fill in the values. I will share some code if
    you like.

    Corey
     
    Corey Scheich, Oct 14, 2003
    #2
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.