PDA

View Full Version : Modify Block


jmcshane
2007-06-22, 04:09 PM
Hi,

I am looking for some direction or advice in how to select a certain LWPOLYLINE
which passes through point 0,0 within a block.

History:
Since day dot, our company has always had the outline of an A1 sheet on the the title block
and always plotted on A0 paper and trimmed to the outline afterwards....
Now that we are moving to A1 size rolls and removing the outline of the A1 sheet,
it has fallen on me to sort out how we are going to plot all the drawings that have been done up until now, on A1 paper.

I have done a search through this forum, and found a snippet by RKMcSwain
containg the following :

(setq sset (ssget "_X" '((0 . "INSERT"))) i 0)
(repeat (sslength sset)
(setq ent (ssname sset i))
(setq obj (entget ent))
(princ "\nBlock Name: ")
(princ (cdr (assoc 2 obj)))
(setq a (tblobjname "BLOCK" (cdr (assoc 2 obj))))
(while (setq a (entnext a))
(setq ea (entget a))
(princ "\n--->Sub-Entity: ")
(princ (cdr (assoc 0 ea)))
(princ " (Handle=")
(princ (cdr (assoc 5 ea)))
(princ ") ")
)
; loop counter
(setq i (1+ i))
)


I just don't know how to find the subentity of the block which is a polyline that passes through 0,0 and delete it.

Any hints, thoughts or advice would be most welcome.

John

Tom Beauford
2007-06-22, 07:55 PM
I just don't know how to find the subentity of the block which is a polyline that passes through 0,0 and delete it.

Any hints, thoughts or advice would be most welcome.

JohnIf I understand correctly you want to remove a polyline that is inside a block. Why not just edit the block, removing the polyline, and reinsert it in all your drawings?

peter
2007-06-24, 09:31 PM
Try this.



(defun C:RemoveLWPolyline (/ lstPoint objItem objReturn)
(vlax-for objBlock (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)))
(if (and (wcmatch (vla-get-name objBlock) "*"); <-Replace * with title block name
(not (wcmatch (vla-get-name objBlock) "*Model_Space*,*Paper_Space*"))
)
(vlax-for objItem objBlock
(if (= (vla-get-objectname objItem) "AcDbPolyline")
(progn
(setq lstPoint (vlax-curve-getClosestPointTo objItem (list 0.0 0.0)))
(if (< (distance lstPoint (list 0.0 0.0)) 0.00000001)
(vla-delete objItem)
)
)
)
)
)
)
)

jmcshane
2007-06-24, 11:19 PM
If I understand correctly you want to remove a polyline that is inside a block. Why not just edit the block, removing the polyline, and reinsert it in all your drawings?

Hi Tom,
I thought about that, but we are talking about maybe thousands of drawings, some with different images of council logos, joints venture title blocks etc etc.... The only thing all these have in common is that they are called "A1-Titleblock" etc. We also have technicians who would rather eat their computer than go and redefine title blocks in old jobs just to plot them out. That's why I am looking for lisp routine. Thanks for your reply all the same.


Peter,

Many many thanks, Your routine works a treat thank you.
How do you know all this stuff?


Regards


John

kpblc2000
2007-06-24, 11:55 PM
Does this LWPOLYLINE has a vertex at 0,0,0?
Do you want to change some dwg at one time?
And finally - what do you want to do with this block? Only delete this LWLPOLYLINE?

peter
2007-06-25, 02:54 PM
Peter,

Many many thanks, Your routine works a treat thank you.
How do you know all this stuff?


Regards


John

I like to program, and use it all the time. I wrote that code for you...just for fun.

As for how do you know all this stuff???

I love to program VLisp, and monitor LISP programming forums and discussion groups.

www.augi.com
www.theswamp.org
www.waun.org

Been doin it for a while.

Peter







Peter