Problem highlighting entity
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Problem highlighting entity

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
ajtruckle
Guest





Posted: Thu Dec 16, 2004 12:10 pm    Post subject: Problem highlighting entity Reply with quote

I have this basic macro:

[pre]
Option Explicit
Public Sub SplitPoly()
Dim ent As AcadObject
Dim basePnt As Variant

On Error Resume Next

Call ThisDrawing.Utility.GetEntity(ent, basePnt, "Please choose an entity to split:")
If Err <> 0 Then
Err.Clear
Else
ent.Highlight
End If

End Sub
[/pre]

But once the macro has executed, the entity (polyline) I selected is not highlighted. I was expecting it to show dashed, as I get when I do this in lisp:

[pre]
(redraw ename 3)
[/pre]

What am I doing wrong?

Back to top
Michel
Guest





Posted: Thu Dec 16, 2004 12:38 pm    Post subject: Re: Problem highlighting entity Reply with quote

You must set the Highlight-property to 'True' :
ent.Highlight True

Michel
Back to top
Alfred NESWADBA
Guest





Posted: Thu Dec 16, 2004 12:42 pm    Post subject: Re: Problem highlighting entity Reply with quote

In article
<1503388.1103181034380.JavaMail.jive@jiveforum1.autodesk.com>,
nospam@address.withheld says...
Quote:
I have this basic macro:

[pre]
Option Explicit
Public Sub SplitPoly()
Dim ent As AcadObject
Dim basePnt As Variant

On Error Resume Next

Call ThisDrawing.Utility.GetEntity(ent, basePnt, "Please choose an entity to split:")
If Err <> 0 Then
Err.Clear
Else
ent.Highlight
End If

End Sub
[/pre]

But once the macro has executed, the entity (polyline) I selected is not highlighted. I was expecting it to show dashed, as I get when I do this in lisp:

[pre]
(redraw ename 3)
[/pre]

What am I doing wrong?

hi


you have to give the parameter 'true' or 'false' with ent.Highlight to
give the input for turning highlight on or off.

==> ent.Highlight True

- alfred -

Back to top
ajtruckle
Guest





Posted: Thu Dec 16, 2004 12:42 pm    Post subject: Re: Problem highlighting entity Reply with quote

Thank you. I have this working. Can I ask you another question? As it is, it will pick any entity whether the entity is visible or not.

Is there a way to:

a) ensure the entity picked is a visible entity and not on a locked layer

b) ensure the entity is a polyline (ie: something that will be acceptable as a parameter to the "break" command).

??

Andrew
Back to top
Michel
Guest





Posted: Thu Dec 16, 2004 1:04 pm    Post subject: Re: Problem highlighting entity Reply with quote

After an entity is picked, you might want to check if the layer is locked and whether the selected entity is a polyline. The sample should get you started. Be careful, there are two types of polylines (AcDbPolyline and AcDb2dPolyline), so might want to check both types.
Checking visibility works the same way: If ent.Visible=True then...


Public Sub SplitPoly()
Dim ent As AcadEntity
Dim basePnt As Variant

On Error Resume Next
ThisDrawing.Utility.GetEntity ent, basePnt, "Please choose an entity to split:"
If Err <> 0 Then
Err.Clear
Else
If ThisDrawing.Layers(ent.Layer).Lock = False And ent.ObjectName = "AcDbPolyline" Then
ent.Highlight True
End If
End If

End Sub
Back to top
ajtruckle
Guest





Posted: Thu Dec 16, 2004 1:56 pm    Post subject: Re: Problem highlighting entity Reply with quote

I did it like this:

[pre]
Option Explicit
Public Sub SplitPoly()
On Error Resume Next

Dim Layer As AcadLayer
Dim ent As AcadObject
Dim basePnt As Variant

InitUserPrompt

SelectEntity:
Call ThisDrawing.Utility.GetEntity(ent, basePnt, _
vbCrLf & "Please choose an entity to split:")
If Err.Number = 0 Then
' Entity must NOT be on a locked or frozen layer
Set Layer = ThisDrawing.Layers(ent.Layer)

If Layer.Lock = True Or Layer.Freeze = True Then
' We must try again!
Call UpdateUserPrompt(" This entity is on a locked or frozen layer!")
GoTo SelectEntity

' Must be valid entity type and the layer must be ON
ElseIf TypeOf ent Is AcadPolyline Or _
TypeOf ent Is AcadLWPolyline Or _
TypeOf ent Is Acad3DPolyline And _
Layer.LayerOn = True Then

Call ent.Highlight(True)

Else
' We must try again!
Call UpdateUserPrompt(" You must select a POLYLINE or 3D POLYLINE.")
GoTo SelectEntity

End If
End If

' Continue with macro

ResetUserPrompt

End Sub

Private Sub ResetUserPrompt()

ThisDrawing.Utility.Prompt (vbCrLf & "Command:")

End Sub

Private Sub UpdateUserPrompt(strPrompt As String)

ThisDrawing.Utility.Prompt (strPrompt)

End Sub

Private Sub InitUserPrompt()

ThisDrawing.Utility.Prompt (vbCrLf)

End Sub

[/pre]
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB