Author Topic: Draw Order of Objects in VBA..  (Read 2068 times)

0 Members and 1 Guest are viewing this topic.

hardwired

  • Guest
Draw Order of Objects in VBA..
« on: February 20, 2008, 09:30:15 AM »
Hi,

Is there a way to sort the draw order out of VBA created objects?

Basically........

Code: [Select]
' Check for correct titleblocks..
Select Case entX.Name
        Case "A3 - AbiCAD Titleblock"
                A3logo_IP(0) = 9.442: A3logo_IP(1) = 5: A3logo_IP(2) = 0
                Set blockLOGO_A3 = ThisDrawing.Blocks.Item("A3 - AbiCAD Titleblock").InsertBlock(A3logo_IP, LogoPath, 1#, 1#, 1#, 0)
                blockLOGO_A3.Layer = "ABI-BORDER"
                blockLOGO_A3.Update
                GoTo RUN_TBE
End Select


....which upon user selection of a client name, it inserts that logo into the main titleblock block, but some logos are full of colour, which should sit behind the main titleblock framing lines..

Is there no draworder properties for these block objects in VBA, or is there another way, if any to do it?

Any ideas?

     Cheers,

Paul
Code: [Select]
basepointdesignzltd..P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..
AutoCAD 2008..

Bryco

  • Water Moccasin
  • Posts: 1849
Re: Draw Order of Objects in VBA..
« Reply #1 on: February 20, 2008, 09:51:09 AM »
AcadSortentsTable, the help is good on this as well.

hardwired

  • Guest
Re: Draw Order of Objects in VBA..
« Reply #2 on: February 20, 2008, 11:42:03 AM »
Hi,

Have looked into it and from somewhere else on the web i copied a bit of code (in red) and modified it for my own purpose:

Code: [Select]
Private Sub cmdUpdateTitleblock_click()
[color=red]'Draworder the LOGO to the back..
Dim eDictionary As Object
Dim sentityObj As Object
Dim A3_STB(0), A2_STB(0), A1_STB(0) As AcadObject
Set eDictionary = ThisDrawing.PaperSpace.GetExtensionDictionary
Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS", "AcDbSortentsTable")[/color]


' Loop through every layout in the drawing..
ThisDrawing.ActiveSpace = acPaperSpace
For Each layoutX In ThisDrawing.Layouts
If layoutX.Name <> "Model" Then 'Disregard ModelSpace..
ThisDrawing.ActiveLayout = layoutX
   
' Start main loop to get attribute values for the attributes..
For Each entX In ThisDrawing.PaperSpace
    ' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then

' Check for correct titleblocks and insert logos. Also, set draworder for blocks to movetobottom..
Select Case entX.Name
        Case "A1 - AbiCAD Titleblock"
                A1logo_IP(0) = 446.415: A1logo_IP(1) = 17.085: A1logo_IP(2) = 0
                Set blockLOGO_A1 = ThisDrawing.Blocks.Item("A1 - AbiCAD Titleblock").InsertBlock(A1logo_IP, LogoPath, 1#, 1#, 1#, 0)
                blockLOGO_A1.Layer = "ABI-BORDER"
                blockLOGO_A1.Update
                [color=red]Set A1_STB(0) = blockLOGO_A1
                sentityObj.MoveToBottom A1_STB[/color]
                AcadApplication.Update
                GoTo RUN_TBE
               
        Case "A2 - AbiCAD Titleblock"
                A2logo_IP(0) = 183.049: A2logo_IP(1) = 5: A2logo_IP(2) = 0
                Set blockLOGO_A2 = ThisDrawing.Blocks.Item("A2 - AbiCAD Titleblock").InsertBlock(A2logo_IP, LogoPath, 1#, 1#, 1#, 0)
                blockLOGO_A2.Layer = "ABI-BORDER"
                blockLOGO_A2.Update
                [color=red]Set A2_STB(0) = blockLOGO_A2
                sentityObj.MoveToBottom A2_STB[/color]
                AcadApplication.Update
                GoTo RUN_TBE
               
        Case "A3 - AbiCAD Titleblock"
                A3logo_IP(0) = 9.442: A3logo_IP(1) = 5: A3logo_IP(2) = 0
                Set blockLOGO_A3 = ThisDrawing.Blocks.Item("A3 - AbiCAD Titleblock").InsertBlock(A3logo_IP, LogoPath, 1#, 1#, 1#, 0)
                blockLOGO_A3.Layer = "ABI-BORDER"
                blockLOGO_A3.Update
                [color=red]Set A3_STB(0) = blockLOGO_A3
                sentityObj.MoveToBottom A3_STB[/color]
                AcadApplication.Update
                GoTo RUN_TBE
End Select
           
RUN_TBE:
'blah blah blah more code here for other stuff...
End Sub


....But this code bottoms-out on the 'sentityObj.MoveToBottom A3_STB', 'sentityObj.MoveToBottom A2_STB' & 'sentityObj.MoveToBottom A1_STB' lines, stating:

'Invalid Input'


What could be wrong? Is it that the logo block is inserted into another block (nested block) or is there a simple solution to this?

Any ideas?

     Cheers,

Paul
basepointdesignzltd..
P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..
AutoCAD 2008..


Bryco

  • Water Moccasin
  • Posts: 1849
Re: Draw Order of Objects in VBA..
« Reply #3 on: February 20, 2008, 12:20:51 PM »
Try making a function.
But first try what help does, I think you may need to work on programming basics.
First you figure out how to do it at all, then you figure out how to adapt that to the particular code you are working on.
It takes time, for everyone.