Jump to content

Split Block Based on Polylines inside


nosscc

Recommended Posts

  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

  • nosscc

    14

  • Roy_043

    10

  • maratovich

    8

  • BIGAL

    7

Top Posters In This Topic

Posted Images

Here is another variant

This is not a lisp is a program

 

Hi Maratovich,

 

This is truely amazing ! Is it possible to have a lisp version of this program?

Because I have 5000+ combined blocks like this, this program can only select one at a time

If possible I would like to modify a little bit, those 5000+ blocks are in different layers, I can "qselect" all of them easily by layer names.

Link to comment
Share on other sites

Good afternoon nosscc.

Processing all the blocks requires a lot of refinement of the program.

I am now very busy with commercial orders.

Write me a personal message, discuss the possibility. Mail or Skype.

Link to comment
Share on other sites

Alan H is the guy in the code you provided to select text within polygon :)

 

BIGAL I think with your brilliant getboundingbox method I have succeeded, now I am able to select a number of blocks, then run lisp, and will split them also rename tags for the 1st and 2nd attributes within each new block

 

But I am having a new problem now and driving me crazy, the code I wrote seemed only working for a limited number of blocks, it is not working properly for a larger selection

 

In this sample drawing attached, there are 68 blocks, if I apply lisp for smaller selection at a time, it worked well

 

But if I select all blocks together, and run lisp, sometimes it gives error :function cancelled, sometimes it split all the blocks in a weird way, like grouping the 2nd attribute of the top rectangle with the 1st and 2nd attributes of the bottom rectangle

 

This is so weird, how is this possible ? BSPLIT.LSP

68blocks.dwg

Link to comment
Share on other sites

@nosscc: Your original post is actually confusing. You also want to handle attributes that are not enclosed in a rectangle. Your last dwg shows the most tricky case so far: at least one attribute ("DA2") is located in the 'wrong rectangle'.

Link to comment
Share on other sites

@maratovich: Not sure what your point is. The only solution I can now come up with is to count the polylines in the block definition and to divide the attribute list based on that number. But creating a new separate block definition for each rectangle seems ill-advised. IMO it would just create a new problem.

Link to comment
Share on other sites

I said at the beginning that there will be different blocks and different attributes.

The initial sample file does not correspond to what the topic author wants.

We need to look for a solution for a long time, and take into account all variants of the author.

Link to comment
Share on other sites

@maratovich: A solution as demonstrated by your animation would not be acceptable IMO. Replacing the original insert with 6 different but almost identical blocks makes no sense.

Link to comment
Share on other sites

I think those extra attributes do not matter, if you look at the code I wrote BSPLIT, which will burst the block first, after that DA, Page numbers, etc are gone, and you will only have 2 texts left within each polygon

My question is, why the lisp I wrote only works for a small selection of blocks, but not working properly/returns error for larger selection ?

Is that a system bug or something ?

Link to comment
Share on other sites

@nosscc:

I have not tested your code, but two things stand out:

 

1. OSMODE issue

Read this:

http://www.cadtutor.net/forum/showthread.php?102290-Multi-leader-Export-Problem&p=694644&viewfull=1#post694644

And/or:

https://www.theswamp.org/index.php?PHPSESSID=10qijkpvecscg6v1uu29sdf3f6&topic=53652.0

 

2. Ssget issue

Since you are using (ssget "_W" ...) which will only select entities that are on-screen, make sure to _Zoom _Extents before using your code.

Link to comment
Share on other sites

Roy+043 If using ssget "_W" it may be better to use a Z C option and zoom out to a desirable scale rather than extents, some other screwy stuff may start to occur bit like the osmode problems as the lisp can not see what its trying to retrieve. Have had those problems before.

 

Maybe a bounding box of the original block then a zoom c then a burst this way zooms to each block but not each pline inside.

 

fixes and suggestions

at start
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
at end 
(setvar 'osmode oldsnap)


(setq ss (ssget (list (cons 0 "Insert")))) ;manually create a selection containing all blocks 
; can use (8 . "layername") (2 . "blockname") as well pick a block 1st and get these two extra bits of info.

(while (< cntr (sslength ss))
(setq obj (ssname ss cntr));retrieve nth entity name in global set

;manually create a selection containing all blocks
; uses repeat loop and if no ss does not run
; use a alert and say (exit) to do again

(if (setq ss (ssget (list (cons 0 "Insert")))) 
(repeat  (setq cntr (sslength ss))
(setq obj (ssname ss (setq cntr (- cntr 1))))  ;retrieve nth entity name in global set last to 1st

Edited by BIGAL
Link to comment
Share on other sites

Thanks guys, you are correct. I tested it is zooming issue, not number of entities.

I selected only 1 entity, worked fine when the block is "big" on my screen, 4 attributes split into 2 - 2 (2 in each block)

Then same entity I selected again but zoomed out, the lisp split 4 attributes into 1-3 (the 2nd attribute in the top rectangle became grouped with 1st and 2nd attributes in the bottom rectangle)

Then I tested again, but zoomed out even further, the lisp grouped 4 attributes into 1 block only, and returned error

 

I will try to add "zoom" in the code and see how it goes

Link to comment
Share on other sites

So far so good, I only added one line

 

(command "zoom" "W" minpt maxpt) ;between "burst" and ssget "W"

 

I think there is no need to zoom out, as the next loop will take my screen to the window of the next block

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...