How to highlight a curve?

How to highlight a curve?

WonkaPet
Advocate Advocate
354 Views
2 Replies
Message 1 of 3

How to highlight a curve?

WonkaPet
Advocate
Advocate

Hi there,

 

I'm trying to mimic the highlight that AutoCAD does during routines like the EXTEND and BREAK commands.

 

My issue is that my entities won't highlight during the world draw but will update after when I add the object to the database does anyone know how I can get my entity to highlight during the world draw? As well, how would I get an entity to become more transparent? My code the the world draw is below:

 

 

  Protected Overrides Function WorldDraw(ByVal draw As WorldDraw) As Boolean

      If _OffsetCurveList IsNot Nothing Then

        For Each oCurve As Curve In _CurveList

          oCurve.Highlight()
          draw.Geometry.Draw(oCurve)

        Next

      End If

  Return True

  End Function

 

 

 

0 Likes
355 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

Without known the context of your code, I'd try to change the order of the code like this, to see what happens:

 

        For Each oCurve As Curve In _CurveList

          draw.Geometry.Draw(oCurve)
          oCurve.Highlight()

        Next

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3

WonkaPet
Advocate
Advocate

Hi Norman,

 

Thanks for the response that didn't work but I'm trying to make an offset command that displays an offset curve. The world draw is used to display the proposed offset curve to the user. I'm not too sure what the best time to do the highlight is but the List of Curves that I'm displaying are generated using the "GetOffsetCurves" command. Does my curve need to be in the database in order to be highlighted? I don't add the object during the world draw.

 

Here's the code I use to build the offset curve.

 

 

  Private Sub objOffset(ByVal offset As Double)

    Dim oDoc As Document = Core.Application.DocumentManager.MdiActiveDocument

    Try

      Dim oDbObjectCollection As DBObjectCollection = Nothing

      Try

        oDbObjectCollection = _SelectedCurve.GetOffsetCurves(offset)

      Catch ex As Exception

      End Try

      If oDbObjectCollection IsNot Nothing AndAlso oDbObjectCollection.Count > 0 Then

        Using oTr As Transaction = oDoc.Database.TransactionManager.StartTransaction

          Dim LayerId As ObjectId

          If _LayerUsage = OffsetLayerUsage.UserDefined AndAlso _LayerName.Length > 0 Then

            Dim layerDir As New LayerDirector
            With layerDir
              .ModType = ModEnum.Assert
              .ModOptionsBuilder.HDatabase = oDoc.Database
              .ModOptionsBuilder.HDocument = oDoc
              .ModOptionsBuilder.HTransaction = oTr
              .ModOptionsBuilder.LayerString = _LayerName
              .ApplyMod()
            End With

            LayerId = layerDir.ProductObjectId

          End If

          For Each oEnt As Entity In oDbObjectCollection

            Dim oCurve As Curve = TryCast(oEnt, Curve)

            oCurve.Highlight()

            If oCurve IsNot Nothing Then _OffsetCurveList.Add(TryCast(oCurve.Clone, Curve))

            Select Case _LayerUsage

              Case OffsetLayerUsage.Current

                oEnt.LayerId = oDoc.Database.Clayer

              Case OffsetLayerUsage.Source

                oEnt.LayerId = _SelectedCurve.LayerId

              Case OffsetLayerUsage.UserDefined

                If LayerId.IsValid Then oEnt.LayerId = LayerId

            End Select

          Next

          oTr.Commit()

        End Using

        oDbObjectCollection.Dispose()

      End If

    Catch ex As Exception
      ReportError(ex)
    End Try

  End Sub

 

0 Likes