Advertisement

09.14.2006 at 07:28AM PDT, ID: 21989469
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

Autocad 2007 VBA-Draw order in a Block

Asked by norrin_radd in CAD & Architecture Software

Tags: , ,

I'm trying to make sure my wipeouts are set behind everything in my blocks. I'm going to eventually work this into happening on insert but for now I'd just like to get it to happen at all by selecting the block.
I've figured out how to use the AcDbSortentsTable to move objects behind in modelspace, I cant get it to work in a block. This code is a combination of updateing a block and moving objects behind from the help files look up "sortentstable example" for that example.
I want to try to avoid having to explode the block and put it back together if I can, not sure if that will work anyway.

Just for reference, this first code is the basic editing a block that works(got it from autodesk's ng):
*********************
Public Sub UpdateBlockDefinition()
Dim Entity As AcadEntity
Dim BlockEntity As AcadEntity
Dim BlockDefinition As AcadBlock
Dim BlockReference As AcadBlockReference
Dim SelectionSet As AcadSelectionSet

On Error Resume Next
ThisDrawing.SelectionSets.Item("BlockToUpdate").Delete
On Error GoTo 0

Set SelectionSet = ThisDrawing.SelectionSets.Add("BlockToUpdate")
SelectionSet.SelectOnScreen

For Each Entity In SelectionSet
If TypeOf Entity Is AcadBlockReference Then
Set BlockReference = Entity
For Each BlockDefinition In ThisDrawing.Blocks
If BlockDefinition.Name = BlockReference.Name Then
For Each BlockEntity In BlockDefinition
' Do your modifications here...
BlockEntity.color = acRed
BlockEntity.Layer = "0"
BlockEntity.Update
Next BlockEntity
End If
Next BlockDefinition
End If
Next Entity
End Sub
*****************
This is the code I pieced together with the above and the sortentstable from the help files.

*******************
Public Sub UpdateBlockDefinition()
Dim Entity As AcadEntity
Dim BlockEntity As AcadEntity
Dim BlockDefinition As AcadBlock
Dim BlockReference As AcadBlockReference
Dim SelectionSet As AcadSelectionSet

'Get an extension dictionary and, if necessary, add a SortentsTable object
    Dim eDictionary As Object
    Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
    ' Prevent failed GetObject calls from throwing an exception
    On Error Resume Next
    Dim sentityObj As Object
    Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
   
    On Error GoTo 0
    If sentityObj Is Nothing Then
         ' No SortentsTable object, so add one
         Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS", "AcDbSortentsTable")
    End If

On Error Resume Next
ThisDrawing.SelectionSets.Item("BlockToUpdate").Delete
On Error GoTo 0

Set SelectionSet = ThisDrawing.SelectionSets.Add("BlockToUpdate")
SelectionSet.SelectOnScreen

   
For Each Entity In SelectionSet
If TypeOf Entity Is AcadBlockReference Then


Set BlockReference = Entity

For Each BlockDefinition In ThisDrawing.Blocks

   
If BlockDefinition.NAME = BlockReference.NAME Then
     
       
For Each BlockEntity In BlockDefinition
' Do your modifications here...

'MsgBox BlockEntity.ObjectName
If BlockEntity.ObjectName = "AcDbWipeout" Then
'MsgBox "wipeout"

     Dim ObjIds(0) As Long
     ObjIds(0) = BlockEntity.ObjectID
     'ObjIds(1) = leaderObj.ObjectID
     Dim varObject As ACADObject
     Set varObject = ThisDrawing.ObjectIdToObject(ObjIds(0))
     Dim arr(0) As ACADObject
     Set arr(0) = varObject

    'MsgBox arr(0).ObjectName

    'Move the object to the bottom
    sentityObj.MoveToBottom arr '**** I get an invalid input error here.
     AcadApplication.Update

End If

Next BlockEntity
End If
Next BlockDefinition
End If
Next Entity
End Sub
*******************

Any help/suggestions would be appreciated.



dragontooth, you did see that DT(bat) signal in the sky last night didnt ya? ;)
http://upload.wikimedia.org/wikipedia/en/a/ad/Bat-signalBatman_1989.jpgStart Free Trial
[+][-]09.14.2006 at 01:42PM PDT, ID: 17524244

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.14.2006 at 02:16PM PDT, ID: 17524499

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.14.2006 at 04:44PM PDT, ID: 17525359

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.15.2006 at 09:19AM PDT, ID: 17530641

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.15.2006 at 09:41AM PDT, ID: 17530793

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.15.2006 at 12:00PM PDT, ID: 17531823

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.15.2006 at 12:21PM PDT, ID: 17531994

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.15.2006 at 12:34PM PDT, ID: 17532084

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.17.2006 at 01:30PM PDT, ID: 17539459

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: CAD & Architecture Software
Tags: autocad, vba, block
Sign Up Now!
Solution Provided By: dragontooth
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09.18.2006 at 10:02AM PDT, ID: 17545040

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32