.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Highlight a block with ObjectARX 2006

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
3058 Views, 14 Replies

Highlight a block with ObjectARX 2006

Hi all,
I am trying to highlight polylines and block references on drawings using AutoCAD 2006, ObjectARX 2006 and VS 2005.

I've been reading some threads on highlighting entities at this forum, and I found a piece of code at http://discussion.autodesk.com/thread.jspa?messageID=5205357
for ObjectARX 2006. I tried it, and it works for the polylines, but I am not able to highlight the block references.

Here is the code I am using to highlight / unhighlight entities:

' --------------------------- CODE STARTS HERE -------------------------

Public Shared Sub HighlightEntity(ByVal entity As Entity, _
ByVal enable As Boolean)

If (entity IsNot Nothing AndAlso entity.Id.IsValid) Then
Dim ids(1) As ObjectId

ids(0) = entity.Id
Dim index As SubentityId = New SubentityId(SubentityType.Null, 0)
Dim path As FullSubentityPath = New FullSubentityPath(ids, index)

If (enable) Then
entity.Highlight(path, True)
Else
entity.Unhighlight(path, True)
End If

Application.DocumentManager.MdiActiveDocument.Editor.UpdateScreen()

End If

End Sub 'HighlightEntity()

' --------------------------- CODE ENDS HERE -------------------------

If you see something strange, or you miss something at this piece of code, please let me know.

Thanks in advance ;-) Message was edited by: rubendm

PS: I tried using each of the possible values of SubentityType, but the result was always the same: it works for Polylines, but not for BlockReferences
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

Hi,

Here is some C# example that works for me.

Database db = acDbService.HostApplicationServices.WorkingDatabase;
using (TransactionManager tm = db.TransactionManager)
{
using (Transaction acadTrans = tm.StartTransaction())
{
try
{
foreach (ObjectId oi in ids)
{
Entity ent = (Entity)tm.GetObject(oi, OpenMode.ForRead);
ent.Highlight();
}
acadTrans.Commit();
}
catch
{
throw;
}
}
}

Hope you find it usefull...

Regards
Peter

wrote in message news:5625938@discussion.autodesk.com...
Hi all,
I am trying to highlight polylines and block references on drawings using
AutoCAD 2006, ObjectARX 2006 and VS 2005.

I've been reading some threads on highlighting entities at this forum, and I
found a piece of code at
http://discussion.autodesk.com/thread.jspa?messageID=5205357
for ObjectARX 2006. I tried it, and it works for the polylines, but I am
not able to highlight the block references.

Here is the code I am using to highlight / unhighlight entities:

' --------------------------- CODE STARTS HERE -------------------------

Public Shared Sub HighlightEntity(ByVal entity As Entity, _
ByVal enable As Boolean)

If (entity IsNot Nothing AndAlso entity.Id.IsValid) Then
Dim ids(1) As ObjectId

ids(0) = entity.Id
Dim index As SubentityId = New SubentityId(SubentityType.Null,
0)
Dim path As FullSubentityPath = New FullSubentityPath(ids,
index)

If (enable) Then
entity.Highlight(path, True)
Else
entity.Unhighlight(path, True)
End If

Application.DocumentManager.MdiActiveDocument.Editor.UpdateScreen()

End If

End Sub 'HighlightEntity()

' --------------------------- CODE ENDS HERE -------------------------

If you see something strange, or you miss something at this piece of code,
please let me know.

Thanks in advance 😉

Message was edited by: rubendm

PS: I tried using each of the possible values of SubentityType, but
the result was always the same: it works for Polylines, but not for
BlockReferences
Message 3 of 15
Anonymous
in reply to: Anonymous

Hi Peter,
Thank you for your help. But I think it won't solve my problem, since I am using ObjectARX 2006. This API version does not have the Entity.Highlight() method without params. The method Highlight receives two parameters:

- The FullSubEntityPath of the entity to highlight
- A Boolean to specify if the entity is going to be highlighted in all the viewports

Anyway, thanks for the effort 😉
Message 4 of 15
Anonymous
in reply to: Anonymous

Ok.

Try this flag :

Dim index As SubentityId = New SubentityId(SubentityType.Vertex, 0)

insted of the one you use :

Dim index As SubentityId = New SubentityId(SubentityType.Null, 0)

Regards
Peter

wrote in message news:5627415@discussion.autodesk.com...
Hi Peter,
Thank you for your help. But I think it won't solve my problem, since I am
using ObjectARX 2006. This API version does not have the Entity.Highlight()
method without params. The method Highlight receives two parameters:

- The FullSubEntityPath of the entity to highlight
- A Boolean to specify if the entity is going to be highlighted in all the
viewports

Anyway, thanks for the effort 😉
Message 5 of 15
Anonymous
in reply to: Anonymous

Look at this thread,
see class HighlihtEntity written by Alexander Rivilis:

http://www.autocad.ru/cgi-bin/f1/board.cgi?t=28934Pr

Hth

~'J'~
Message 6 of 15
Anonymous
in reply to: Anonymous

Fatty - do you know the difference between Managed
ObjectARX and native ObjectARX (e.g., C++) ?

The thread you refer the OP to is native ObjectARX.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5627507@discussion.autodesk.com...
Look at this thread,
see class HighlihtEntity written by Alexander Rivilis:

http://www.autocad.ru/cgi-bin/f1/board.cgi?t=28934Pr

Hth

~'J'~
Message 7 of 15
Anonymous
in reply to: Anonymous

Yes, dear sir, I know it
The essence of my logic is other, namely:
when somebody will search in this news group
"ObjectARX" then it can see the reference on
my site
Only advertising and is more than anything
You are satisfied, sir?
Message 8 of 15
Anonymous
in reply to: Anonymous

Sorry, I don't understand.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5627724@discussion.autodesk.com...
Yes, dear sir, I know it
The essence of my logic is other, namely:
when somebody will search in this news group
"ObjectARX" then it can see the reference on
my site
Only advertising and is more than anything
You are satisfied, sir?
Message 9 of 15
Anonymous
in reply to: Anonymous

THank you 🙂

~'J'~
Message 10 of 15
Anonymous
in reply to: Anonymous

Hi again, Peter:

I tried it, but it still does not work with the block references

Anyway, thanks for your help 😉
Message 11 of 15
Anonymous
in reply to: Anonymous

Hi Fatty,
I saw the thread you referred, but (as Tony said) this is unmanaged C++ code. I need to solve this using the .NET ObjectARX 2006 API.

Anyway, thanks for your help
Message 12 of 15
Anonymous
in reply to: Anonymous

What about this: http://through-the-interface.typepad.com/through_the_interface/2006/12/highlighting_a_.html ?
Message 13 of 15
Anonymous
in reply to: Anonymous

Hi Ruben.

Are you using a Transaction like my first example code shows?
I think you will need that to highlight the objects.

Regards Peter

wrote in message news:5633320@discussion.autodesk.com...
Hi again, Peter:

I tried it, but it still does not work with the block references

Anyway, thanks for your help 😉
Message 14 of 15
Anonymous
in reply to: Anonymous

Thanks a lot Alexander. It worked!!!!!

Sorry for the delay, but I could not test it until yesterday. I think Kean did it again 😉

Thanks again!!!!
Message 15 of 15
harryliu3140
in reply to: Anonymous

Hi,

 

I find this topic when I want to access the faces of a 3DSolid.The code showed above give a path to the answer.

 

I change the code like this and it highlight the face for me:

 

        Dim index As SubentityId = New SubentityId(SubentityType.Face, 1)

Seems the index of subentity start from 1. When I change 1 to 2 it highlight the next face, but when the index bigger than the number of faces it give me an error.

 

Still don't know how to find the number of faces.

 

Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost