TheSwamp
Code Red => VB(A) => Topic started by: jura on August 20, 2004, 02:01:12 PM
-
I was wondering if i can control the draworder by using vba. I can't seem to
find which property controls the draworder.
Something like this: (stripped down version)
Sub Block2Front()
Dim BlockSSet As AcadSelectionSet
Dim VarBlock As Variant
Set BlockSSet = ThisDrawing.SelectionSets.Add("block")
BlockSSet.SelectOnScreen
For Each VarBlock In BlockSSet
VarBlock.XXXXXXX = "Front"
Next
BlockSSet.Delete
End Sub
Thx to Devitg for pointing me to the swamp. Thought i'd lost this after
Cadalog closed the forum. What is the stoy behind that btw. Thought they
(the new owners) promised to leave the forum intact. Was it interfering too much with their commecial thoughts?
-
I was wondering if i can control the draworder by using vba. I can't seem to
find which property controls the draworder.
Something like this: (stripped down version)
Sub Block2Front()
Dim BlockSSet As AcadSelectionSet
Dim VarBlock As Variant
Set BlockSSet = ThisDrawing.SelectionSets.Add("block")
BlockSSet.SelectOnScreen
For Each VarBlock In BlockSSet
VarBlock.XXXXXXX = "Front"
Next
BlockSSet.Delete
End Sub
Hi...
You test with SendCommand:
Sub Block2Front()
Dim BlockSSet As AcadSelectionSet
Dim VarBlock As Variant
Set BlockSSet = ThisDrawing.SelectionSets.Add("block")
BlockSSet.SelectOnScreen
ThisDrawing.SendCommand "_.draworder" & vbCr & "_p" & vbCr & vbCr & "_Front" & vbCr
BlockSSet.Delete
End Sub
-
That's a fine solution for setting the draworder. Thx
The draworder however must be stored in a value somewhere. Is it possible to catch this value to store it in a variabel.
-
That's a fine solution for setting the draworder. Thx
The draworder however must be stored in a value somewhere. Is it possible to catch this value to store it in a variabel.
From the DXF reference on SORTENTSTABLE:
If the SORTENTS Regen flag (bit-code value 16) is set, AutoCAD regenerates entities in ascending handle order. When the DRAWORDER command is used, a SORTENTSTABLE object is attached to the *Model_Space or *Paper_Space block's extension dictionary under the name ACAD_SORTENTS. The SORTENTSTABLE object related to this dictionary associates a different handle with each entity which redefines the order that the entities are regenerated.
It appears that the data saved in this table is NOT accessible with VBA/ActiveX. It IS available to Lisp:
(setq layouts (vla-get-layouts *doc*))
(setq ms (vla-item layouts "Model"))
(setq blk (vla-get-block ms))
(if (= :vlax-true (vla-get-hasextensiondictionary blk))
(progn
(setq dict (vla-getextensiondictionary blk))
(setq item (vla-item dict 0))
(setq ename (vlax-vla-object->ename item))
(entget ename)
)
)
HTH
-
Why isn't that available in VBA? Looks quite easily accessible to me... Just get the current document from the Application object, and the rest of the code would be the VBA-equivalents to your post...
And for what it's worth, you can get modelspace (what you called blk in your code) directly from the active document:
(setq ms (vla-get-modelSpace *doc*))
(if (= :vlax-true (vla-get-hasExtensionDictionary ms))
...
)
-
Why isn't that available in VBA? Looks quite easily accessible to me... Just get the current document from the Application object, and the rest of the code would be the VBA-equivalents to your post...
And for what it's worth, you can get modelspace (what you called blk in your code) directly from the active document:
[
I know I could get the MS direct, but if you want to find the draworder for any layout, you need the block associated with that layout......
What is the VBA equivalent to (entget) that will return the DXF codes? If you look at the Object returned With the dict.item(0), there is nothing associated with it...... :?
-
Thought this was easy.
-
Jeff, I've been trying to write a VB app to control draw order by layer. Looks like this is the right discussion topic. It looks like it's easier to do in LISP but I can't get it to write back to the drawing so that next time I run the routine, it would recall the last draw order. But again, I'm not a VB expert. Did anyone has any success with this?
That's a fine solution for setting the draworder. Thx
The draworder however must be stored in a value somewhere. Is it possible to catch this value to store it in a variabel.
From the DXF reference on SORTENTSTABLE:
If the SORTENTS Regen flag (bit-code value 16) is set, AutoCAD regenerates entities in ascending handle order. When the DRAWORDER command is used, a SORTENTSTABLE object is attached to the *Model_Space or *Paper_Space block's extension dictionary under the name ACAD_SORTENTS. The SORTENTSTABLE object related to this dictionary associates a different handle with each entity which redefines the order that the entities are regenerated.
It appears that the data saved in this table is NOT accessible with VBA/ActiveX. It IS available to Lisp:
(setq layouts (vla-get-layouts *doc*))
(setq ms (vla-item layouts "Model"))
(setq blk (vla-get-block ms))
(if (= :vlax-true (vla-get-hasextensiondictionary blk))
(progn
(setq dict (vla-getextensiondictionary blk))
(setq item (vla-item dict 0))
(setq ename (vlax-vla-object->ename item))
(entget ename)
)
)
HTH
-
Hi CADwoman,
You don't say what version you are using. Starting with 2004 or 2005 the SortentsTable was placed into the Acad API. All of my experience in the previous discussion was based on 2002. If you have a newer version, I'd start by looking at the ActiveX Developer help for SortentsTable.
-
I've written a solution in Vlisp, should be possible to translate that into VBA:
Visit my homepage -> Free Stuff and search for 'VxSetDrawOrder'
-
I am using ACAD2006. The SortentsTable sound like a good place to start. Since I'm not good with VB, it'll take me a while.
Hi CADwoman,
You don't say what version you are using. Starting with 2004 or 2005 the SortentsTable was placed into the Acad API. All of my experience in the previous discussion was based on 2002. If you have a newer version, I'd start by looking at the ActiveX Developer help for SortentsTable.
-
In VBA, could you not get all layers, sort that by number or alphabetically, and use draworder on that list?