Continue to Site

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!

Scale in Note. 1

Status
Not open for further replies.

tighthead

Mechanical
Dec 18, 2001
11
How do we include the scale of a view in a note on a draaawing (linked)?
SW2005 sp0.
 
Replies continue below

Recommended for you

No thats not it, thread559-155291
Thats basically the standard SW help.
When you have a standard view (not detail etc).
We put multiple parts on one sheet & sometimes scale them differently, how can we show the scale for each part on the drawing in a note:
We have good reasons to do this.
 
tighthead,

Here is some code I wrote awhile back that may help you.

Regards,

Regg

Code:
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModelDoc As SldWorks.ModelDoc2
Dim swDrawing As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim swNote As SldWorks.note
Dim swAnnotation As SldWorks.Annotation
Dim swSelection() As Object

Dim ScaleRatio As Variant
Dim ViewCorners As Variant
Dim SelectionIndex As Long

Sub main()

    'attach to SolidWorks
    Set swApp = Application.SldWorks
    
    'get active document
    Set swModelDoc = swApp.ActiveDoc
    
    'check for document
    If swModelDoc Is Nothing Then
    
        MsgBox "No active document.     ", vbOKOnly + vbCritical, "Label View Scale"
        Exit Sub
        
    End If
    
    'check if document is drawing
    If swModelDoc.GetType = swDocDRAWING Then
    
        Set swDrawing = swModelDoc
        
    Else
    
        MsgBox "Active document must be drawing.    ", vbOKOnly + vbCritical, "Label View Scale"
        Exit Sub
        
    End If
    
    'get selection manager
    Set swSelMgr = swModelDoc.SelectionManager
    
    'check if anything selected
    If swSelMgr.GetSelectedObjectCount = 0 Then
    
        MsgBox "No views selected.    ", vbOKOnly + vbCritical, "Label View Scale"
        Exit Sub
        
    Else
    
        'save selections
        ReDim swSelection(1 To swSelMgr.GetSelectedObjectCount) As Object
    
        'check if selection is drawing view
        For SelectionIndex = 1 To swSelMgr.GetSelectedObjectCount
        
            If swSelMgr.GetSelectedObjectType2(SelectionIndex) = swSelDRAWINGVIEWS Then
            
                Set swSelection(SelectionIndex) = swSelMgr.GetSelectedObject5(SelectionIndex)
                
            End If
            
        Next

    End If
    
    'analize selections
    For SelectionIndex = 1 To swSelMgr.GetSelectedObjectCount
    
        'check if selected object is view
        If swSelection(SelectionIndex) Is Nothing Then
        
            MsgBox "Selected object " & SelectionIndex & " is not a drawing view.     ", vbOKOnly + vbExclamation, "Label View Scale"
            
        Else
        
            'get selected view
            Set swView = swSelection(SelectionIndex)
            
            'get view scale
            ScaleRatio = swView.ScaleRatio
            
            'get view corner locations
            ViewCorners = swView.GetOutline
                
            'lock view focus so note will move if corresponding view moved
            swView.FocusLocked = True
            
            'create note
            Set swNote = swDrawing.InsertNote("Scale " & ScaleRatio(0) & ":" & ScaleRatio(1))
            
            'set note angle
            swNote.angle = 0
            
            'set note is balloon to no
            swNote.SetBalloon 0, 0
            
            'get note annotation object
            Set swAnnotation = swNote.GetAnnotation
            
            'set note leader to none
            swAnnotation.SetLeader2 False, 0, True, False, False, False
            
            'locate note 10mm right from left edge and 5mm below from bottom edge of view bounding box
            swAnnotation.SetPosition ViewCorners(0) + 0.01, ViewCorners(1) - 0.005, 0
            
            'unlock  view focus
            swView.FocusLocked = False
            
        End If
        
    Next
            
    'refresh graphics screen
    swModelDoc.WindowRedraw
    
End Sub
 
I apoligize for my misunderstanding of your post. There is one possibility to make a linked note, but it's sort of hoky, and you may not want to do it. You would have to make each view either a detail view or auxiliary view of a view that's off the sheet printable area. You would also have to manually line up the different views of each part. Go to Tools->Options->Document Properties->Detailing->View Labels and change the view label format to show only the scale.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor