Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

2007 inspection dim numbers 2

Status
Not open for further replies.

remj

Mechanical
Aug 29, 2003
19
US
SW2007 sp2.2

Is there a way to assign numbers to the dims of a dwg for inspection purposes?

For example, you have a detailed dwg, our qc guy writes numbers next to each dim in order to reference to his report. I would like for SW to automatically assign those numbers & place them next to the dims. Is that possible?
 
Replies continue below

Recommended for you

That is not a built-in function of SW.

An API guru may be able to create a macro which recognises the dimensions in a drawing and adds a consecutive number to each.

[cheers]
 
remj-
Why not place a modifying symbol in the Dimension Text box?
ex: 10.00 <C#-1> would give you 10.00 w/ 1 in a circle. It should only take an extra click or two on each dimension.
 
Check out thread559-193453. If you are so inclined, you may be able to modify it to incorporate felix7502's suggestion.
 
Great ideas, thanks. I was also thinking of attaching numbers in a different layer so I can turn them on/off
 
felix7502,

What a cool feature!

I notice that <T#-1> and <S#-1> also work.

It is a shame that <T#-B> does not work, since this would be a good way to flag revisions.

JHG
 
drawoh,
Apparently, the symbol capability of SW is fairly unknown. You can add any symbol into a dimension using the <****> notation as long as you know what the symbol code is. To find out the symbol code, pick a dimension and then click "More..." in the "Dimension Text" area of the property manager. Choose "Flag Tri A-Z" from the "Symbol Library" combo box, and choose "Triangle B" beneath. Then click OK. The triangle B will appear on the drawing, and the code "<TL-B>" will be shown the "Dimension Text" box of the property manager. You now know that the code for a letter inside a triangle is "<TL-*>", where * is the letter you want.

remj,
Adding the reference numbers to a different layer would be more difficult to do with a macro. The reference number would have to be a separate annotation rather than a part of the dimension, and the annotation would have to be grouped with the dimension to make sure that it maintains its position relative to the dimension when the dimension moves.

If anyone is interested, here is the code to insert felix's symbols to all drawing dimensions:

Code:
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swDwg As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swDispDim As SldWorks.DisplayDimension
Dim swDim As SldWorks.Dimension
Dim sCurSuffix As String
Dim nOpenParPos As Long
Dim nCloseParPos As Long
Dim vDimVal As Variant
Dim dInchVal As Double
Dim sInchString As String
Dim sNewSuffix As String
Dim KillFlag As Integer
Dim sMsg As String
Dim sRefPfx As String
Dim nRefNum As Long
Const DEFSYM As String = "C#-"


Sub AddDimRefNums()

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc

If swDoc.GetType <> swDocDRAWING Then
    MsgBox "This macro only works for drawing files."
    Exit Sub
End If

sMsg = "This macro will add a symbol containing a dimension reference number " & _
        vbCrLf & "to all dimensions in this drawing." & vbCrLf & vbCrLf & _
        "To add or update dimension reference symbols, choose ""Yes""" & vbCrLf & _
        "To remove reference symbols, choose ""No""" & _
        vbCrLf & "To quit, choose ""Cancel"""
KillFlag = MsgBox(sMsg, vbYesNoCancel, "Dimension Reference Symbols")

If KillFlag = vbCancel Then
    Exit Sub
End If

If KillFlag = vbYes Then
    sRefPfx = InputBox("Please enter the desired symbol code." & vbCrLf & _
                        "For example, ""C#-"" for circles, ""S#-"" for squares." & vbCrLf & _
                        "Note that symbol codes are case sensitive.", "Symbol Type", DEFSYM)
Else
    sRefPfx = ""
End If

Set swDwg = swDoc

nRefNum = 1

Set swView = swDwg.GetFirstView
While Not (swView Is Nothing)
    Set swDispDim = swView.GetFirstDisplayDimension5
    While Not swDispDim Is Nothing
        Set swDim = swDispDim.GetDimension
        sInchString = sRefPfx & nRefNum
        nRefNum = nRefNum + 1
        sCurSuffix = swDispDim.GetText(swDimensionTextSuffix)
        nOpenParPos = InStr(1, sCurSuffix, "<", vbTextCompare)
        nCloseParPos = InStr(1, sCurSuffix, ">", vbTextCompare)
        If (KillFlag = vbNo) And (nOpenParPos > 0) And (nCloseParPos > 0) Then
            sNewSuffix = Left(sCurSuffix, nOpenParPos - 1)
            sNewSuffix = sNewSuffix & Right(sCurSuffix, Len(sCurSuffix) - nCloseParPos)
        ElseIf (nOpenParPos > 0) And (nCloseParPos > 0) Then
            sNewSuffix = Left(sCurSuffix, nOpenParPos)
            sNewSuffix = sNewSuffix & sInchString
            sNewSuffix = sNewSuffix & Right(sCurSuffix, Len(sCurSuffix) - (nCloseParPos - 1))
        Else
            If KillFlag <> vbNo Then
                sNewSuffix = Trim(sCurSuffix) & " <" & sInchString & ">"
            Else
                sNewSuffix = sCurSuffix
            End If
        End If
        swDispDim.SetText swDimensionTextSuffix, sNewSuffix
        Set swDispDim = swDispDim.GetNext5
    Wend
    Set swView = swView.GetNextView
Wend


End Sub
 
[sigh] A buck short and a day late (well 5 minutes anyway) as usual. [smile]

Good one Handleman

[cheers]
 
Handleman,

It looks like christmas came a little late for me this year, but thanks so much for the macro. [santa3]

I've had the same "problem" and have just been doing this manually forever.

I'm wondering one thing though, is it somehow possible to beat/work around the limitation of 99 dimensions? We do the same thing (which we refer to as "ballooning") and sometimes we make balloon prints with a few hundred dimensions. After the 99th we have to make a note with a circular border.

Thoughts, feelings, suggestions????


 
4zengineering,

Check out CBL's great FAQ on custom symbols at faq559-1229. All you have to do is modify your gtol.sym file to add as many numbers as you want. However, you should note that once you get above 99 the numbers may start overlapping the box/circle/whatever.
 
My gtol.sym has the following as the circle size:

*99,Circle 99
A,CIRCLE .8,.5,.8
A,TEXT .8,.5,99

By revising the size of the X and the Radius the 150 fits in nicely. The size of the enclosing circle isn't that much different from the 2 digit circle.

*150,Circle 150
A,CIRCLE .9,.5,.9
A,TEXT .9,.5,150

You can tweak as needed.

Note that this would have to be included on all your work stations, otherwise I don't think it will show up except on the ones that have this revision.

Sylvia
 
InspectionXpert generates quality inspection sheets automatically from SolidWorks drawings and also identifies them on the drawing. The website is still under construction but you can go to the for more information. TriMech Solutions currently sells the application.
 
handleman,

I ran your macro, great time saver, but it only works on the active page. Is there a way to get this to work on all pages? Or add in a start number? I tried c#-16 and it caused problems <c#-161> so does c#1.

I have not tried writing my own macros but it appears this would be a pretty useful skill to learn.

thank you for your time and efforts
 
Adding in a start number would be pretty easy. Just find the line:

nRefNum = 1

and change it to

nRefNum = InputBox("Enter the starting number","",1)

It's been a while since I looked at this code, but I think that should work. Of course, it error out or behave strangely if you don't enter a number.
 
handleman

YOU ARE AWESOME!!!!!

Thank you, You probably just saved me a couple hours a week.
 
Macro writing is most definitely a useful skill to learn, and can really save you a lot of time down the road if you can take the time to learn it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top