Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

draworder within blocks

26 REPLIES 26
Reply
Message 1 of 27
Anonymous
525 Views, 26 Replies

draworder within blocks

The express tools cdorder does this - but i'd like to automate it more

I also like the 'handles' solution becuase it is better between xrefs - and
draworder/sortents corruption seems to be a bit of a problem on 2004
stations

as a side note:

draworderctl is 3
sortents is 127
treedepth is 3020

I tried the following:

gather all hatch layers in the drawing (including with blocks)

then step through all objects and if they are not on one of the hatch layers
do an (entdel en) (entdel en)
I tried the same approach stepping through a block but the results are
mixed.

we have large elevations ($ 450 million tower) with all kinds of blocks with
multiple hatches... and running draworder during refedit can causes
thousands of erros ( in the sortents table) I even downloaded the lisp from
autodesk which 'fixes' sortents table stuff...but to no avail.
And cdorder doesn't really do a good job either.

Any ideas?

(2004 sp2 win xp sp 2)

Jamie
26 REPLIES 26
Message 21 of 27
Anonymous
in reply to: Anonymous

Jamie,

Sorry about the delayed reply.

The code I posted is "dangerous" in the sense if anything goes wrong while copying
and erasing objects within block definitions, you might end up with corrupt or
incomplete blocks. For instance, there is no error checking for locked layers.

Joe Burke


"The Dark Princess" wrote in message
news:6012462@discussion.autodesk.com...
I have tested the code and it does exactly as you described, my fault for
not understanding it at first.
I only need to tweak the if statement...

Again, if you please, what does the 'dangerous bit' refer to?

Jamie


"Joe Burke" wrote in message
news:6012106@discussion.autodesk.com...
Jamie,

Again you fail to reply to the question asked. "Post an example file which
demonstrates the code I posted does not work." Whether it is dangerous or
not has
nothing to do with the validity of the code.

Joe

"Princess Jamie" wrote in message
news:6011157@discussion.autodesk.com...
perhaps you can explain the bit dangerous part.

Jamie

"Joe Burke" wrote in message
news:6011028@discussion.autodesk.com...
Post an example file which demonstrates the code I posted does not work.

Joe

"The Dark Princess" wrote in message
news:6010317@discussion.autodesk.com...
Thank you for your input.

This does nothing in addressing the problem, namely revising the handles of
objects within blocks so that these objects will be visually above the other
objects, but it teaches me more about vlisp which is great.

Jamie




"Joe Burke" wrote in message
news:6004006@discussion.autodesk.com...
Jamie,

Something like this for the blocks. Test it on copies of working files. It
is a
bit dangerous.

Joe

[code]
;; Hatch to back in blocks example.
;; Minimal error checking.
(defun c:H2B ( / doc blocks copylst)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq blocks (vla-get-blocks doc))
(vlax-for x blocks
(if
(and
(zerop (vlax-get x 'IsXref))
(not (eq "*MODEL_SPACE" (strcase (vlax-get x 'Name))))
(not (eq "*PAPER_SPACE" (strcase (vlax-get x 'Name))))
)
(vlax-for i x
(if (not (eq "AcDbHatch" (vlax-get i 'ObjectName)))
(setq copylst (cons i copylst))
)
)
)
(if copylst
(progn
(vlax-invoke doc 'CopyObjects (reverse copylst) x)
(mapcar 'vla-delete copylst)
)
)
(setq copylst nil)
)
(vla-regen doc acActiveViewport)
(princ)
) ;end
[/code]

"The Dark Princess" wrote in message
news:6003242@discussion.autodesk.com...
sorry Joe! sorry sorry - here, have a timbit...:-)

on the bottom please


so I need to copy the entites in the block other than hatches and entities
on hatch layers....

got it


not sure how to do that while stepping through the block's objects

Jamie
Message 22 of 27
Anonymous
in reply to: Anonymous

ah, thanks. I have considered the locking of layers in other portions of
the code. I was thninking that might be the case. Thanks

Jamie
"Joe Burke" wrote in message
news:6015888@discussion.autodesk.com...
Jamie,

Sorry about the delayed reply.

The code I posted is "dangerous" in the sense if anything goes wrong while
copying
and erasing objects within block definitions, you might end up with corrupt
or
incomplete blocks. For instance, there is no error checking for locked
layers.

Joe Burke


"The Dark Princess" wrote in message
news:6012462@discussion.autodesk.com...
I have tested the code and it does exactly as you described, my fault for
not understanding it at first.
I only need to tweak the if statement...

Again, if you please, what does the 'dangerous bit' refer to?

Jamie


"Joe Burke" wrote in message
news:6012106@discussion.autodesk.com...
Jamie,

Again you fail to reply to the question asked. "Post an example file which
demonstrates the code I posted does not work." Whether it is dangerous or
not has
nothing to do with the validity of the code.

Joe

"Princess Jamie" wrote in message
news:6011157@discussion.autodesk.com...
perhaps you can explain the bit dangerous part.

Jamie

"Joe Burke" wrote in message
news:6011028@discussion.autodesk.com...
Post an example file which demonstrates the code I posted does not work.

Joe

"The Dark Princess" wrote in message
news:6010317@discussion.autodesk.com...
Thank you for your input.

This does nothing in addressing the problem, namely revising the handles of
objects within blocks so that these objects will be visually above the other
objects, but it teaches me more about vlisp which is great.

Jamie




"Joe Burke" wrote in message
news:6004006@discussion.autodesk.com...
Jamie,

Something like this for the blocks. Test it on copies of working files. It
is a
bit dangerous.

Joe

[code]
;; Hatch to back in blocks example.
;; Minimal error checking.
(defun c:H2B ( / doc blocks copylst)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq blocks (vla-get-blocks doc))
(vlax-for x blocks
(if
(and
(zerop (vlax-get x 'IsXref))
(not (eq "*MODEL_SPACE" (strcase (vlax-get x 'Name))))
(not (eq "*PAPER_SPACE" (strcase (vlax-get x 'Name))))
)
(vlax-for i x
(if (not (eq "AcDbHatch" (vlax-get i 'ObjectName)))
(setq copylst (cons i copylst))
)
)
)
(if copylst
(progn
(vlax-invoke doc 'CopyObjects (reverse copylst) x)
(mapcar 'vla-delete copylst)
)
)
(setq copylst nil)
)
(vla-regen doc acActiveViewport)
(princ)
) ;end
[/code]

"The Dark Princess" wrote in message
news:6003242@discussion.autodesk.com...
sorry Joe! sorry sorry - here, have a timbit...:-)

on the bottom please


so I need to copy the entites in the block other than hatches and entities
on hatch layers....

got it


not sure how to do that while stepping through the block's objects

Jamie
Message 23 of 27
Anonymous
in reply to: Anonymous

"Joe Burke" wrote in message
news:6015888@discussion.autodesk.com...
Jamie,

Sorry about the delayed reply.




...heeheehee. Joe- you are a funny guy.
And now back to "The Bickersons"...

Regards,
David Kozina
Message 24 of 27
Anonymous
in reply to: Anonymous

David,

I meant what I said. No humor or sarcasm intended.

Regards
Joe


"David Kozina" <"David Kozina"> wrote in message
news:6017165@discussion.autodesk.com...
"Joe Burke" wrote in message
news:6015888@discussion.autodesk.com...
Jamie,

Sorry about the delayed reply.




...heeheehee. Joe- you are a funny guy.
And now back to "The Bickersons"...

Regards,
David Kozina
Message 25 of 27
craigswancott
in reply to: Anonymous

The code which you published is exactly what I need to overcome a similar problem, unfortunately I keep getting an error '; error: AutoCAD.Application: Object not in database' I am using Acad2009. All my blocks are in modelspace and are hatched using solid hatch, so I have tried substituting AcDbHatch with AcDbSolid, just in case, but with the same results. Could it possibly be because not all my blocks contain hatch.

Apologies for butting in on the old thread, but I think this is the most appropriate method, anyway any help would be greatly appreciated.

Regards

Craig
Message 26 of 27
craigswancott
in reply to: Anonymous

I need to change the draworder of hatch within blocks, to send it to the back. I have created the blocks the correct way, but when they are inserted into a new drawing the order gets mixed up.

I have looked at the posting and the code written by Joe, but I can not get this to work using AutoCAD 2009. It would not matter if all hatch within the drawing was sent to the back, as long as this could include the hatch within blocks. Maybe I am missing something simple in running the code?

Please could someone kindly help me with this, as I do not know where to start.

Many Thanks.

Craig.
Message 27 of 27
Anonymous
in reply to: Anonymous


it's easier for us to rely not on draworder which
establishes a dictionary that may not be honored in xrefs -blocks in your case-
RATHER make use of the order in which entities are created and make sure
SORTENTS = 48

 

to send your hatch to the back:

._COPY _ALL _Remove <select the hatch> 0,0
0,0

._ERASE _Previous


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
need to change the draworder of hatch within blocks, to send it to the back. I
have created the blocks the correct way, but when they are inserted into a new
drawing the order gets mixed up. I have looked at the posting and the code
written by Joe, but I can not get this to work using AutoCAD 2009. It would
not matter if all hatch within the drawing was sent to the back, as long as
this could include the hatch within blocks. Maybe I am missing something
simple in running the code? Please could someone kindly help me with this, as
I do not know where to start. Many Thanks. Craig.

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

Post to forums  

”Boost