Dimension color macro
Dimension color macro
(OP)
I haven't found a particular thread on this, but there are some that are close. We purchased a couple of Konica Minolta Bizhub C250'S color laser printers and now print dimensions on one layer. BOM's, notes, balloons on another layer.
From "Macro for layer color change?" thread
http://www .eng-tips. com/viewth read.cfm?q id=166199& amp;page=2
I know the colors for the 2 layers.
I also read "How to find OVERRIDE Dimensions in a drawing?"
http://www .eng-tips. com/viewth read.cfm?q id=165835& amp;page=1
Which gave me the idea for this macro.
Objective
Dims layer color = 771752142
text layer color = 10944512
If BOM's, notes, baloons would be too much trouble, I would settle for help on just getting the dims on there own layer.
SW06 SP5.0
From "Macro for layer color change?" thread
http://www
I know the colors for the 2 layers.
I also read "How to find OVERRIDE Dimensions in a drawing?"
http://www
Which gave me the idea for this macro.
Objective
- Automatically find dimensions and place them on existing "Dims" layer.
- Automatically find BOM's, Leaders, Notes and place them on existing "Text layer.
Dims layer color = 771752142
text layer color = 10944512
If BOM's, notes, baloons would be too much trouble, I would settle for help on just getting the dims on there own layer.
SW06 SP5.0






RE: Dimension color macro
swCThread
swDatumTag
swDatumTargetSym
swDisplayDimension
swGTol
swNote
swSFSymbol
swWeldSymbol
swCustomSymbol
swDowelSym
swLeader
swCenterMarkSym
swCenterLine
swDatumOrigin
swWeldBeadSymbol
Which annotations to you want moved to which layers? I assume swDisplayDimension goes to the "Dims" layer, but I'm guessing you don't want every one of these anotations on the "Text" layer.
RE: Dimension color macro
swBlock
swCenterLine
swCenterMarkSym
swCThread
swCustomSymbol
swDatumOrigin
swDatumTag
swDatumTargetSym
swDisplayDimension
swDowelSym
swGTol
swLeader
swNote
swSFSymbol
swTableAnnotation
swWeldBeadSymbol
swWeldSymbol
You should be able to add/switch etc these to the code below:
CODE
Const TEXTLAYERCOLOR As Long = 10944512
Const DIMSLAYERCOLOR As Long = 771752142
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swDwg As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swAnnot As SldWorks.Annotation
Dim sMsg As String
Dim swLyrMgr As SldWorks.LayerMgr
Dim swLayer As SldWorks.Layer
Sub MoveDimsAndTablesToLayers()
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
Set swDwg = swDoc
Set swLyrMgr = swDoc.GetLayerManager
If COLORQUERY Then
Set swLayer = swLyrMgr.GetLayer(swLyrMgr.GetCurrentLayer)
MsgBox "The color of layer " & swLayer.Name & " is " & swLayer.Color
Exit Sub
End If
Set swLayer = swLyrMgr.GetLayer("Text")
swLayer.Color = TEXTLAYERCOLOR
Set swLayer = swLyrMgr.GetLayer("Dims")
swLayer.Color = DIMSLAYERCOLOR
Set swView = swDwg.GetFirstView
While Not (swView Is Nothing)
Set swAnnot = swView.GetFirstAnnotation3
While Not swAnnot Is Nothing
If swAnnot.GetType = swDisplayDimension Then
swAnnot.Layer = "Dims"
ElseIf swAnnot.GetType = swNote Then
swAnnot.Layer = "Text"
ElseIf swAnnot.GetType = swTableAnnotation Then
swAnnot.Layer = "Text"
End If
Set swAnnot = swAnnot.GetNext3
Wend
Set swView = swView.GetNextView
Wend
Set swLayer = Nothing
Set swLyrMgr = Nothing
Set swAnnot = Nothing
Set swView = Nothing
Set swDwg = Nothing
Set swDoc = Nothing
Set swApp = Nothing
End Sub
RE: Dimension color macro
SW06 SP5.0
Flores
RE: Dimension color macro
Is there anyway to either skip this layer or skip that text?
SW06 SP5.0
Flores
RE: Dimension color macro
RE: Dimension color macro
CODE
Const TEXTLAYERCOLOR As Long = 10944512
Const DIMSLAYERCOLOR As Long = 771752142
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swDwg As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swAnnot As SldWorks.Annotation
Dim sMsg As String
Dim swLyrMgr As SldWorks.LayerMgr
Dim swLayer As SldWorks.Layer
Sub MoveDimsAndTablesToLayers()
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
Set swDwg = swDoc
Set swLyrMgr = swDoc.GetLayerManager
If COLORQUERY Then
Set swLayer = swLyrMgr.GetLayer(swLyrMgr.GetCurrentLayer)
MsgBox "The color of layer " & swLayer.Name & " is " & swLayer.Color
Exit Sub
End If
Set swLayer = swLyrMgr.GetLayer("Text")
swLayer.Color = TEXTLAYERCOLOR
Set swLayer = swLyrMgr.GetLayer("Dims")
swLayer.Color = DIMSLAYERCOLOR
Set swView = swDwg.GetFirstView
While Not (swView Is Nothing)
Set swAnnot = swView.GetFirstAnnotation3
While Not swAnnot Is Nothing
If swAnnot.Layer = "Not For Production" Then
'Skip this annotation
ElseIf swAnnot.GetType = swDisplayDimension Then
swAnnot.Layer = "Dims"
ElseIf swAnnot.GetType = swNote Then
swAnnot.Layer = "Text"
ElseIf swAnnot.GetType = swTableAnnotation Then
swAnnot.Layer = "Text"
End If
Set swAnnot = swAnnot.GetNext3
Wend
Set swView = swView.GetNextView
Wend
Set swLayer = Nothing
Set swLyrMgr = Nothing
Set swAnnot = Nothing
Set swView = Nothing
Set swDwg = Nothing
Set swDoc = Nothing
Set swApp = Nothing
End Sub
RE: Dimension color macro
handleman, for some odd reason the text for "-NOT FOR PRODUCTION-" was still put on the text layer and turned to the text layer color. I fiddled with it and added:
Const PRODUCTIONLAYERCOLOR As Long = 771752142
and
Set swLayer = swLyrMgr.GetLayer("Not for Production")
swLayer.Color = PRODUCTIONLAYERCOLOR
and it is working now.
CODE
Const TEXTLAYERCOLOR As Long = 10944512
Const DIMSLAYERCOLOR As Long = 771752142
Const PRODUCTIONLAYERCOLOR As Long = 771752142
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swDwg As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swAnnot As SldWorks.Annotation
Dim sMsg As String
Dim swLyrMgr As SldWorks.LayerMgr
Dim swLayer As SldWorks.Layer
Sub MoveDimsAndTablesToLayers()
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
Set swDwg = swDoc
Set swLyrMgr = swDoc.GetLayerManager
If COLORQUERY Then
Set swLayer = swLyrMgr.GetLayer(swLyrMgr.GetCurrentLayer)
MsgBox "The color of layer " & swLayer.Name & " is " & swLayer.Color
Exit Sub
End If
Set swLayer = swLyrMgr.GetLayer("Text")
swLayer.Color = TEXTLAYERCOLOR
Set swLayer = swLyrMgr.GetLayer("Dims")
swLayer.Color = DIMSLAYERCOLOR
Set swLayer = swLyrMgr.GetLayer("Not for Production")
swLayer.Color = PRODUCTIONLAYERCOLOR
Set swView = swDwg.GetFirstView
While Not (swView Is Nothing)
Set swAnnot = swView.GetFirstAnnotation3
While Not swAnnot Is Nothing
If swAnnot.Layer = "Not for Production" Then
'Skip this annotation
ElseIf swAnnot.GetType = swDisplayDimension Then
swAnnot.Layer = "Dims"
ElseIf swAnnot.GetType = swNote Then
swAnnot.Layer = "Text"
ElseIf swAnnot.GetType = swTableAnnotation Then
swAnnot.Layer = "Text"
End If
Set swAnnot = swAnnot.GetNext3
Wend
Set swView = swView.GetNextView
Wend
Set swLayer = Nothing
Set swLyrMgr = Nothing
Set swAnnot = Nothing
Set swView = Nothing
Set swDwg = Nothing
Set swDoc = Nothing
Set swApp = Nothing
End Sub
SW06 SP5.0
Flores