xref display order

xref display order

Anonymous
Not applicable
1,095 Views
19 Replies
Message 1 of 20

xref display order

Anonymous
Not applicable
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
1,096 Views
19 Replies
Replies (19)
Message 2 of 20

Anonymous
Not applicable
Dave, this example might be easier to understand. To test it, start a new
drawing with just two objects in ModelSpace, with displayed lineweights to
make it easier to see it work.

Sub Test()
Dim myDrawOrder As AcadSortentsTable
Set myDrawOrder = GetSortentsTable

Dim myObjects(0) As AcadObject
Set myObjects(0) = ThisDrawing.ModelSpace(0)

myDrawOrder.MoveToTop myObjects
End Sub

Private Function GetSortentsTable() As AcadSortentsTable
On Error Resume Next
Set GetSortentsTable = _
ThisDrawing.ModelSpace.GetExtensionDictionary("ACAD_SortEnts")
If Err.Number <> 0 Then
Set GetSortentsTable = _
ThisDrawing.ModelSpace.GetExtensionDictionary.AddObject("ACAD_SortEnts",
_
"AcDbSortentsTable")
End If
End Function


--
R. Robert Bell


"Dave Preston" wrote in message
news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 3 of 20

Anonymous
Not applicable
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Dave Preston" wrote in message news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 4 of 20

Anonymous
Not applicable
Good point.

--
R. Robert Bell


"Tony Tanzillo" wrote in message
news:4983878@discussion.autodesk.com...
...
The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:
0 Likes
Message 5 of 20

Anonymous
Not applicable
OOps. In the first Sub, "GetSortentsTable" should
have been just "SortentsTable". I must have been
looking at Robert's code to figure out how to write
that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message news:4983878@discussion.autodesk.com...
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Dave Preston" wrote in message news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 6 of 20

Anonymous
Not applicable
Always the master of tact.

--
----
Ed
----
"Tony Tanzillo" wrote in message
news:4984059@discussion.autodesk.com...
OOps. In the first Sub, "GetSortentsTable" should
have been just "SortentsTable". I must have been
looking at Robert's code to figure out how to write
that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4983878@discussion.autodesk.com...
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Dave Preston" wrote in message
news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 7 of 20

Anonymous
Not applicable
Hey guys - I hope your 'squabble' is tongue in cheek? Thanks both for your
input.
All I can say Tony is that the code that I posted is straight out of the VBA
help (with a minmor amendment for the entity used), which uses the things
that you are criticising.
I will try it and see how I get on.

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Tony Tanzillo" wrote in message
news:4984059@discussion.autodesk.com...
OOps. In the first Sub, "GetSortentsTable" should
have been just "SortentsTable". I must have been
looking at Robert's code to figure out how to write
that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4983878@discussion.autodesk.com...
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Dave Preston" wrote in message
news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 8 of 20

Anonymous
Not applicable
I'm still geting errors with this. Are you sure you can pass it an xref to
send to the back?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Dave Preston" wrote in message
news:4984551@discussion.autodesk.com...
Hey guys - I hope your 'squabble' is tongue in cheek? Thanks both for your
input.
All I can say Tony is that the code that I posted is straight out of the VBA
help (with a minmor amendment for the entity used), which uses the things
that you are criticising.
I will try it and see how I get on.

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Tony Tanzillo" wrote in message
news:4984059@discussion.autodesk.com...
OOps. In the first Sub, "GetSortentsTable" should
have been just "SortentsTable". I must have been
looking at Robert's code to figure out how to write
that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4983878@discussion.autodesk.com...
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Dave Preston" wrote in message
news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 9 of 20

Anonymous
Not applicable
Just to clarify this. If I add a circle and use .MoveToBottom it works, but
if I try the same with an xref I get error "-2145386493 Invalid Input" on
the line

myDrawOrder.MoveToBottom oEntities

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Dave Preston" wrote in message
news:4984587@discussion.autodesk.com...
I'm still geting errors with this. Are you sure you can pass it an xref to
send to the back?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Dave Preston" wrote in message
news:4984551@discussion.autodesk.com...
Hey guys - I hope your 'squabble' is tongue in cheek? Thanks both for your
input.
All I can say Tony is that the code that I posted is straight out of the VBA
help (with a minmor amendment for the entity used), which uses the things
that you are criticising.
I will try it and see how I get on.

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Tony Tanzillo" wrote in message
news:4984059@discussion.autodesk.com...
OOps. In the first Sub, "GetSortentsTable" should
have been just "SortentsTable". I must have been
looking at Robert's code to figure out how to write
that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4983878@discussion.autodesk.com...
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Dave Preston" wrote in message
news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 10 of 20

Anonymous
Not applicable
>> All I can say Tony is that the code that I posted is
>> straight out of the VBA help (with a minmor amendment
>> for the entity used), which uses the things that you are criticising.

Hi Dave. The examples you get from the HELP are generally
intended to show basic usage without confusing the issue
with other, more advanced optimizations or design patterns,
like not coupling the code to ThisDrawing or a given space.

In most cases, the help examples don't demonstrate or take
those type of higher-level design aspects into consideration.

The basic rule of thumb, is that if you are operating at the
entity or object level, then you get the owner or containing
space and the document, from the entity/object, rather than
using "ThisDrawing", or a specific owner like Modelspace.

That allows the code to be used in any document, and with
an entity in any space/block.

I'm not sure about xrefs and draworder, but if it works with
most simple entities and not xrefs, there's something else
mucking up the works. Post your code.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
0 Likes
Message 11 of 20

Anonymous
Not applicable
Dave, are you moving the *reference* of the xref insertion, or trying to
move all the objects in the xref (wrong idea)?

--
R. Robert Bell


"Dave Preston" wrote in message
news:4984603@discussion.autodesk.com...
Just to clarify this. If I add a circle and use .MoveToBottom it works, but
if I try the same with an xref I get error "-2145386493 Invalid Input" on
the line

myDrawOrder.MoveToBottom oEntities

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Dave Preston" wrote in message
news:4984587@discussion.autodesk.com...
I'm still geting errors with this. Are you sure you can pass it an xref to
send to the back?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Dave Preston" wrote in message
news:4984551@discussion.autodesk.com...
Hey guys - I hope your 'squabble' is tongue in cheek? Thanks both for your
input.
All I can say Tony is that the code that I posted is straight out of the VBA
help (with a minmor amendment for the entity used), which uses the things
that you are criticising.
I will try it and see how I get on.

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
"Tony Tanzillo" wrote in message
news:4984059@discussion.autodesk.com...
OOps. In the first Sub, "GetSortentsTable" should
have been just "SortentsTable". I must have been
looking at Robert's code to figure out how to write
that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Tony Tanzillo" wrote in message
news:4983878@discussion.autodesk.com...
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Dave Preston" wrote in message
news:4983209@discussion.autodesk.com...
I want an xref to display behind the current drawing. I have tried the
sortents example but get an "invalid input" error on the last line

Dim xRef As String 'as built xref
Dim oBlockDef as acadBlock

xRef = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 6) & "ASP"
Set oBlockDef = ThisDrawing.Blocks.Item(xRef)

Dim eDictionary As Object
Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
On Error Resume Next
Dim sentityObj As Object
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
On Error GoTo 0
If sentityObj Is Nothing Then
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS",
"AcDbSortentsTable")
End If

Dim ObjIds(0) As Long
ObjIds(0) = oBlockDef.ObjectID

Dim varObject As AcadObject
Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
Dim arr(0) As AcadObject
Set arr(0) = varObject

sentityObj.MoveToBottom arr


Anyone had success with this before or know why it's failin?

--
Dave Preston
Technical Dev. Engineer
C A Design Services Limited
Address: Design Centre, Hewett Rd, Gapton Hall,
GREAT YARMOUTH,
Norfolk 31 0NN,
Tel: 01493 440444,
Fax: 01493 442480,

E-Mail: dpreston@cadesignservices.co.uk,
Web Site: www.cadesignservices.co.uk,

Registered in England No. 1595687

This e-mail and any attached files is confidential and intended for the
addressee(s) only. It may contain privileged and confidential information,
and may not be disclosed to anyone else. Unauthorised recipients are
requested to preserve this confidentiality by deleting the original and to
advise the sender immediately of any mistakes in transmission. Internet
communications are not secure and therefore C A Design Services Limited does
not accept any legal responsibility for the contents of this message, and
the message and files are opened at the risk of the recipient. Unless
otherwise specifically stated any views or opinions are solely those of the
author and do not represent those of C A De
0 Likes
Message 12 of 20

Anonymous
Not applicable
I tried to modify this to move to bottom and use a hatch as the acad entity, but without luck. Anybody know if this works with hatches?
0 Likes
Message 13 of 20

Anonymous
Not applicable
Yes it does.

However, you fail to mention what version you are trying this on, and did
not post your code attempt.

--
R. Robert Bell


wrote in message news:4988672@discussion.autodesk.com...
I tried to modify this to move to bottom and use a hatch as the acad entity,
but without luck. Anybody know if this works with hatches?
0 Likes
Message 14 of 20

Anonymous
Not applicable
While you're at it, you may want to avoid making the "stupid, lame-brain"ed mistake of calling a 'GetSortentsTable' function which you have not defined... as Tony does. Further, you may want to avoid making a "stupid, lame-brain"ed mistake of simply changing the call to:

Set SortentsTable = SortentsTable(Entities(0))

because, while that doesn't get you a compile error, it WILL generate the much less desirable run-time error. I'd suggest changing the function name to 'RetSortentsTable'. I like this convention for my functions because Gets, Lets and Sets tend to remind me of properties. While you're modifying the function, be sure to correct the "stupid, lame-brain"ed mistake of typing

'Err Clear'

when you mean

Err.Clear

Also, when checking for errors, it's safer to use

If Err.Number<>0 Then

rather than

If Err Then

The latter relies on VB to convert the default property (Number - an integer) to a Boolean value - a poor programming practice. Be warned, however, that even after you change the function name and so on, Tony's code contains the "stupid, lame-brain"ed mistake of trying to call a function defined with an AcadEntity argument, but passing a variant variable:

Set SortentsTable = RetSortentsTable(Entities(0))

At least this "stupid, lame-brain"ed mistake generates a compile error instead of a run-time error. You could add code to pick off the first entity from the variant and use it to set a variable defined as an AcadEntity then pass that to the RetSortentsTable function... although that might mean "making stupid, lame-brain assumptions about" what's in the variant in the first place. So you might want to put in some code to check that assumption - or risk run-time errors at the most inopportune times. There is probably also a consideration of whether the variant is 'ByRef' or 'ByVal' - VB defaults to 'ByRef' (and that's the only way objects and arrays go) so you're safe in this case. A more robust and reusable rendering of the code, and one that demonstrates some good coding practices by all contributors might be:

Public Sub MoveToTop(Entities() As AutoCAD.AcadEntity)
Dim SortentsTable As AutoCAD.AcadSortentsTable

Set SortentsTable = RetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

Public Function RetSortentsTable(Entity As AcadEntity) As AutoCAD.AcadSortentsTable
Dim Space As AutoCAD.AcadBlock

Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set RetSortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err.Clear
Set RetSortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function

Notice that using the full type library specs in defining my variables (AutoCAD.AcadSortentsTable, etc.), I'm going to know by intellisense whether I've got a version of AutoCAD that actually defines that type.

So, skimming this entire thread, I'd have to score it thusly:

The generous and helpful Bob Bell: 3
1) Putting Dave on to SortEnts to solve your problem
2) Pointing out that Dave should be going after the block ref (insert/instance) instead of the block def.
3) Asking what version of AutoCAD Dave is using.

Tony T: A big, fat zero
1) Making a mountain out of the relative molehil that the entities and the Sortents table might not be in the current drawing's modelspace. (If you're going to assume that, why assume that all of the entities are in the SAME drawing and/or space?)
2) Proclaiming as poor programming practice Bob's use of AcadObject when he might have more properly used AcadEntity. (I'm not sure there are any hard and fast rules about using the lowest level object available. Although I do grant that, in this case, Dave might have been put wise when he tried to set the AcadEntity variable to a block.)

A scant 2.5 years after the fact, maybe the discussion group has provided a decent answer to Dave's original post!

------------------------
Reply From: Tony Tanzillo
Date: Oct/13/05 - 12:38 (CDT)

Re: xref display order
Try to avoid the poor coding habits Robert's example
demonstrates.

Namely, they are coupling code to "ThisDrawing" and/or
to a given space (like Modelspace), and also dimensioning
what must be an AcadEntity, as an AcadObject.

The right way to go about this is to get the document
and the space the entity resides in from the entity itself,
rather than making stupid, lame-brain assumptions about
where it is:

' Move an array of AcadEntities to the top of the draw order:

Public Sub MoveToTop(Entities As Variant)
Dim SortentsTable As AcadSortentsTable
Set SortentsTable = GetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

' Pass an AcadEntity and get its associated sortents table
' Note that we get the document and the block that contains
' the entity from the entity itself, rather than making
' assumptions about where the entity is. Hence, the code
' is much more reusable

Public Function SortentsTable(Entity As AcadEntity) As AcadSortentsTable
Dim Space As AcadBlock
Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set SortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err Then
Err Clear
Set SortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function
0 Likes
Message 15 of 20

Anonymous
Not applicable
What's most entertaining about your comment is not your low-blow/cheap-shot nit-picking of my completely untested, typed-on-the-fly code, but rather, how far back you had to go to find something to make an issue out of.

That, in and of itself, spells "pathetic".

I can probably guess what other name(s) you post under here, but to perfectly honest with you, I have much more interesting things to think about.

Is there a clinical name for the psychological disorder you suffer from?

I'll put my money on Asperger's Syndrome.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
0 Likes
Message 16 of 20

Anonymous
Not applicable
"What's most entertaining about your comment is not your low-blow/cheap-shot nit-picking"

As compared to your unnecessary and undeserved ambush of Robert? Yet you expect others to be circumspect and tolerant? Sure, I could have phrased things a LOT of different ways... and so could you.

"my completely untested, typed-on-the-fly code"

That'll learn ya! Maybe the extra time you'll need to invest to avoid future pillory will cut down a little on amount of snide remarks and outright abuse you can include in your posts?

"how far back you had to go to find something to make an issue out of"

Not at all - searched on 'draworder' and sorted by date. I think this was the first I with useful code. Or maybe I saw your name and figured, you're generally helpful among the abuse. I honestly don't remember.

"I can probably guess what other name(s) you post under here"

No, you couldn't. I never post here under any other name. I rarely visit and even more rarely post.

"Is there a clinical name for the psychological disorder you suffer from?"

If there is, I don't know it. I believe the lay term is 'dude-who-lives-to-pinprick-overinflated-egos'. We'll see if you take the spankings as well as you serve them up. Unlike Robert, you invited this upon yourself - what's the clinical name for that psychological disorder? This is the last post I'll make to this thread because this kind of exchange doesn't add anything to the technical content of the discussion group. 359 degrees of apology to almost all.
0 Likes
Message 17 of 20

Anonymous
Not applicable
Perhaps you should've gone back further in your search, to find a post that would have allowed you to learn why we wrote functions that did not take arrays as parameters. If you had, your cheap shot wouldn't have backfired right in your face, and you wouldn't have to feel nearly as stupid as you will when you learn why that function didn't take an array parameter.

--
http://www.caddzone.com

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

wrote in message news:5911689@discussion.autodesk.com...
"What's most entertaining about your comment is not your low-blow/cheap-shot nit-picking"

As compared to your unnecessary and undeserved ambush of Robert? Yet you expect others to be circumspect and tolerant? Sure, I could have phrased things a LOT of different ways... and so could you.

"my completely untested, typed-on-the-fly code"

That'll learn ya! Maybe the extra time you'll need to invest to avoid future pillory will cut down a little on amount of snide remarks and outright abuse you can include in your posts?

"how far back you had to go to find something to make an issue out of"

Not at all - searched on 'draworder' and sorted by date. I think this was the first I with useful code. Or maybe I saw your name and figured, you're generally helpful among the abuse. I honestly don't remember.

"I can probably guess what other name(s) you post under here"

No, you couldn't. I never post here under any other name. I rarely visit and even more rarely post.

"Is there a clinical name for the psychological disorder you suffer from?"

If there is, I don't know it. I believe the lay term is 'dude-who-lives-to-pinprick-overinflated-egos'. We'll see if you take the spankings as well as you serve them up. Unlike Robert, you invited this upon yourself - what's the clinical name for that psychological disorder? This is the last post I'll make to this thread because this kind of exchange doesn't add anything to the technical content of the discussion group. 359 degrees of apology to almost all.
0 Likes
Message 18 of 20

Anonymous
Not applicable
I have been afforded the opportunity to add further technical content to the thread by correcting my posted code with a change I suggested, but didn't actually implement. So for those careless copy/pasters among us:

Public Sub MoveToTop(Entities() As AutoCAD.AcadEntity)
Dim SortentsTable As AutoCAD.AcadSortentsTable

Set SortentsTable = RetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

Public Function RetSortentsTable(Entity As AcadEntity) As AutoCAD.AcadSortentsTable
Dim Space As AutoCAD.AcadBlock

Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set RetSortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err.Number <> 0 Then
Err.Clear
Set RetSortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function

Finally (and I mean finally), Tony, if you have a cite, make it. Else, I'm thinkin'...straw...grasp. I"ve never felt stupid from being educated - regardless how the lesson is delivered.

--------------
Reply From: Tony Tanzillo
Date: Apr/22/08 - 16:11 (CDT)

Re: xref display order
Perhaps you should've gone back further in your search, to find a post that would have allowed you to learn why we wrote functions that did not take arrays as parameters. If you had, your cheap shot wouldn't have backfired right in your face, and you wouldn't have to feel nearly as stupid as you will when you learn why that function didn't take an array parameter.
0 Likes
Message 19 of 20

Anonymous
Not applicable
I'll give you a hint: Check the VBA version history and see what release of VBA was the first to allow typed array parameters.

--
http://www.caddzone.com

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

wrote in message news:5911975@discussion.autodesk.com...
I have been afforded the opportunity to add further technical content to the thread by correcting my posted code with a change I suggested, but didn't actually implement. So for those careless copy/pasters among us:

Public Sub MoveToTop(Entities() As AutoCAD.AcadEntity)
Dim SortentsTable As AutoCAD.AcadSortentsTable

Set SortentsTable = RetSortentsTable(Entities(0))
SortentsTable.MoveToTop Entities
End Sub

Public Function RetSortentsTable(Entity As AcadEntity) As AutoCAD.AcadSortentsTable
Dim Space As AutoCAD.AcadBlock

Set Space = Entity.Document.ObjectIdToObject(Entity.OwnerID)
On Local Error Resume Next
Set RetSortentsTable = Space.GetExtensionDictionary("ACAD_SORTENTS")
If Err.Number <> 0 Then
Err.Clear
Set RetSortentsTable = Space.GetExtensionDictionary.AddObject _
("ACAD_SORTENTS", "AcDbSortentsTable")
End If
End Function

Finally (and I mean finally), Tony, if you have a cite, make it. Else, I'm thinkin'...straw...grasp. I"ve never felt stupid from being educated - regardless how the lesson is delivered.

--------------
Reply From: Tony Tanzillo
Date: Apr/22/08 - 16:11 (CDT)

Re: xref display order
Perhaps you should've gone back further in your search, to find a post that would have allowed you to learn why we wrote functions that did not take arrays as parameters. If you had, your cheap shot wouldn't have backfired right in your face, and you wouldn't have to feel nearly as stupid as you will when you learn why that function didn't take an array parameter.
0 Likes
Message 20 of 20

Anonymous
Not applicable
Oh, brother. In a vain attempt to save face, Tony has resorted to some
arcane, historical "nit-picking" as a means of spreading F.U.D. This is
unfortunate on two fronts. Firstly, it is truly 'arcane' and therefore
*known* to the initiate. Secondly, in the process he has committed yet
another sizable technical blunder that demands correction.

Yes, yes. Those of us with the scars of many battles all remember the
bad old days of R14.01, 2000, probably 2000i, and maybe even 2002 when
the VBA version in AutoCAD could not pass an array as a parameter. I
am certain that limitation did not exist in 2004 and may have ended in
2002 or before. The original post was mid-October of 2005 which would
have made the current AutoCAD version 2004 and may have even fallen at
a time when 2005 pre-release versions were available. It would be a
coin toss which of us was making the "stupid, lame-brain"ed assumption
on the version without asking. Me? I'm an optimist.

More egregious is his defense of using the Variant data type. Let's
see what Wikipedia has to say about it:

http://en.wikipedia.org/wiki/Variant_type

"While the use of variants in general (and especially of not explicitly
declared variants in the case of Visual Basic) is not recommended, they
can be of use when the needed data type can only be known at runtime,
when the data type is expected to vary, or when optional parameters and
parameter arrays are desired."

In other words, don't use it unless you must. And that really gets to
the crux of Tony's blunder. He waded into this discussion 'cause he
was going to tell us all about good programming practices. Then, without
verifying requirements, he recommends using a dangerous - even obsolete -
data type. Now, he tries to suggest that he did that on purpose in order
to provide backward compatibility - again without that requirement ever
having been imposed. Taken in sum, he is essentially claiming, "Good
programming practices require that you should always code for backward
compatibility." That statement goes beyond bad coding practice and
actually enters the realm of oxymoron.
http://www.merriam-webster.com/dictionary/oxymoron

I guess Tony is going to feel really, really stupid as I triumphantly
inform him that, all of that VB .NET code he is currently writing...
(dramatic pause) is not compatible with my original AutoCAD 2.17 for
the Texas Instruments PC (gasp!!!).

In my universe, time never runs backward, but has a nasty tendency to
run forward. So good programming practices demand that I try to code
for the future. Which is exactly the methodology I've been pushing
in this thread. Using fully qualified data types (AutoCAD.AcadEntity),
not relying on default properties, and abhorring the Variant type were
things I believe I picked up at some .NET presentation. Let's see how
that Wikipedia article continues:

"Among the major changes in Visual Basic .NET, being a .NET language, the
variant type was replaced with the .NET object type. There are similarities
in concept, but also major differences, and no direct conversions exist
between these two types."

But, what if you are really forced to use a Variant because, quoting
the earlier Wikipedia ref, the "needed data type can only be known at
runtime"? If you really couldn't narrow down the data type to some
high level object - AutoCAD.AcadEntity, AutoCAD.AcadObject, or even
Object. And you further didn't even know whether you'd be getting
one of those or an array... (geez, maybe you'd better take another
look at your requirements!) A forward-looking implementation might
appear as the code below. Fleshing out this construct with some
error-handling should result in a very flexible yet robust piece of
code. This serves as a decent reference for what you can and can't
get away with in converting VB data types in the current version of
AutoCAD VBA. It should also put you in good readiness to migrate to
VB .NET. That process would amount to renaming all of the SomeProcBlah
functions to 'SomeProc' and deleting the original SomeProc function.
As I understand it, VB .NET will let you 'overload' procedures and
that means you can have several with the same name, but different
input data types. This long thread gives a nice background for why
that might be important. Personally, I am going to pick up C# .NET
in hopes of having less chance of suffering syntax confusion between
languages.

I'll let Tony have the last word - just call me a name and don't say
something technically refutable.

Sub Testy()
Dim i As Integer, ia() As Integer, l As Long
Dim dbl As Double, dbla() As Double, o() As Object

i = 43
l = 777777
ReDim ia(0 To 2)
ia(0) = 4
dbla = ThisDrawing.GetVariable("UCSORG")
ReDim o(0 To 1)
Set o(0) = ThisDrawing.ModelSpace
Set o(1) = ThisDrawing.PaperSpace
' Try calling SomeProc with the variables
' defined above as arguments. As coded
' here, you'll always get back a 'Nothing'
' value
End Sub

Public Function SomeProc(Arg1 As Variant) As Object
Dim dblPass() As Double, intPass() As Integer
Dim objPass() As Object, i As Integer

Select Case VBA.VarType(Arg1)
Case vbDouble
Set SomeProc = SomeProcDouble(VBA.CDbl(Arg1))
Case vbInteger, vbLong
Set SomeProc = SomeProcWhole(VBA.CLng(Arg1))
Case vbArray + vbDouble
dblPass = Arg1
Set SomeProc = SomeProcDoubleArr(dblPass)
Case vbArray + vbInteger
intPass = Arg1
Set SomeProc = SomeProcIntArr(intPass)
Case vbArray + vbObject
ReDim objPass(LBound(Arg1) To UBound(Arg1))
For i = LBound(Arg1) To UBound(Arg1)
Set objPass(i) = Arg1(i)
Next
Set SomeProc = SomeProcObjArr(objPass)
End Select
End Function

Public Function SomeProcDouble(Arg1 As Double) As Object
Dim RetObj As Object

' Code to set RetObj ref here
Set SomeProcDouble = RetObj
End Function

Public Function SomeProcDoubleArr(Arg1() As Double) As Object
Dim RetObj As Object

' Code to set RetObj ref here
Set SomeProcDoubleArr = RetObj
End Function

Public Function SomeProcWhole(Arg1 As Long) As Object
Dim RetObj As Object

' Code to set RetObj ref here
Set SomeProcWhole = RetObj
End Function

Public Function SomeProcIntArr(Arg1() As Integer) As Object
Dim RetObj As Object

' Code to set RetObj ref here
Set SomeProcIntArr = RetObj
End Function

Public Function SomeProcObjArr(Arg1() As Object) As Object
Dim RetObj As Object

' Code to set RetObj ref here
Set SomeProcObjArr = RetObj
End Function



--------------
Reply From: Tony Tanzillo
Date: Apr/22/08 - 18:57 (CDT)

Re: xref display order
I'll give you a hint: Check the VBA version history and see what release of
VBA was the first to allow typed array parameters.
0 Likes