Discussion:
SolidWorks API to check Sheet Size
(too old to reply)
Randy
2003-10-14 18:25:40 UTC
Permalink
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
Corey Scheich
2003-10-14 19:41:18 UTC
Permalink
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
Post by Randy
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
Loading...