4 Replies Latest reply on May 29, 2014 12:43 PM by Klaudiusz Skiba

    Changing color of dimension on solidwork drawing

    Klaudiusz Skiba

      Hi all, this is my first official post, but not last.

      I'm using Solidworks 2013 SP3

      I'm in the process of creating auto balloning macro that does few extra things.

      I'm adding ballons using displaydimension and placing on either side <#-1> so i get balloons

      My problem is that i would like to make those ballons red but leave dimensions black.

      Any pointers are highly welcome.




        • Re: Changing color of dimension on solidwork drawing
          Klaudiusz Skiba

          Does anybody have a clue if that is even doable? To clarify I'm only looking for change color of dimension. No need for whole code just some pointers.


            • Re: Changing color of dimension on solidwork drawing
              Artem Taturevych

              Could you please send the sample part with such dimension? Not sure how exactly you added the baloon to display dimension.

                • Re: Changing color of dimension on solidwork drawing
                  Klaudiusz Skiba

                  Thank you for reply.

                  Ok here is the part of the code for adding balloons, it's from a macro I found on the forum.

                  My goal is to be able to set  sNewSuffix  to be red. I tried few aproaches but couldn't get it.





                  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

                  Global Killflag As Integer

                  Global locationSelection As String

                  Dim sMsg As String

                  Public sRefPfx As String

                  Global nRefNum As Long

                  Const DEFSYM As String = "C#-"







                  Public Function AddDimRefNums()



                  Set swApp = Application.SldWorks

                  Set swDoc = swApp.ActiveDoc





                  If swDoc.GetType <> swDocDRAWING Then

                      MsgBox "This macro only works for drawing files."

                      Exit Function

                  End If



                  sRefPfx = DEFSYM



                  Set swDwg = swDoc

                  If nRefNum < 1 Then

                  nRefNum = 1

                  End If



                  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(locationSelection)


                          nOpenParPos = 0

                          nCloseParPos = 0

                          If sCurSuffix Like "*<" & Replace(sRefPfx, "#", "[#]") & "*>*" Then

                              nOpenParPos = InStr(1, sCurSuffix, "<" & sRefPfx, vbTextCompare)

                              nCloseParPos = InStr(nOpenParPos, sCurSuffix, ">", vbTextCompare)

                          End If

                          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))




                              If Killflag <> vbNo Then

                                  sNewSuffix = Trim(sCurSuffix) & " <" & sInchString & ">"


                                  sNewSuffix = sCurSuffix

                              End If

                          End If


                          swDispDim.SetText locationSelection, sNewSuffix

                          Set swDispDim = swDispDim.GetNext5


                      Set swView = swView.GetNextView




                  End Function

              • Re: Changing color of dimension on solidwork drawing
                Klaudiusz Skiba

                The only solution I can see to it is to create balloons in notes that are associated with dimensions.