Jump to content

Select polylines by text inside them (long shot)


rdp

Recommended Posts

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • rdp

    12

  • lrm

    11

  • Dadgad

    2

  • BIGAL

    1

Top Posters In This Topic

Posted Images

I added a loop around the program to look at all text and then run the program for each text string. I think this may be what you want. Try version 2.0.

 

I still have to address the minor bug of a text node being inline with a polyline vertex. To temporarily address this problem just move offending text slightly in the y direction.

FindPoly-v2.0.lsp

Link to comment
Share on other sites

Hello Irm,

 

IT WORKS! well, kind of, I'll explain with images.

 

First of all, with too many polys it breaks, it says "too many intersections" (something along those lines, my autocad is not in english). So I have tested with around 200 polys.

 

And then there is something going on with the zoom level. When I zoom to the extent of the drawing, this happens:

 

attachment.php?attachmentid=60784&cid=1&stc=1

 

 

If I zoom out a little, there are less of those lines, but it still doesn't work.

 

I I zoom really far out, then it works (I have given each layer a color for clarification):

 

attachment.php?attachmentid=60785&cid=1&stc=1

 

:)

 

It makes some mistakes depending on the zoom level (it assigns polys to wrong layers). But I find that at a zoom factor of 0.05 for my drawing, it is almost flawless.

 

So a BIG thank you!. Even if its not perfect, it's going to save me a TON of work (probably wouldn't be able to do it without the script).

 

I attached the sample in case that you want to test it some more, but really, this is great as it is, it makes me want to learn autolisp

capture 1.jpg

capture 2.jpg

sample 5.dwg

Link to comment
Share on other sites

I am glad it works even if "kind of". I made a minor change that I think fixes the zoom level issue. Try out version 2.1.

 

As I noted, the program draws a line from the text node to a point 10,000 units to the right and then counts the number of intersections with this line and every polyline in the drawing (not frozen). To select the line and find out its name I was selecting it at the text node. I wasn't happy with this method and as you discovered it is sensitive to the zoom scale. So instead of using the line command to create the long line I've made a change in v2.1 that creates the line directly in vlisp and therefore can get its name directly. This change seems to address the zoom level issue as the sensitivity of selecting at a point is a function of zoom.

 

The 10,000 unit length line is a bit of a kludge. It restricts your drawings to being no larger than 10,000 units wide (measure from the text node). You can make this number larger by editing the line:

 

(setq xp (list (+ 10000 (nth 0 txtnode)) ; point +x direction

 

Those long horizontal lines are present in some of the pictures you posted are the temporary lines the program creates that did not get deleted (but should have).

 

I could look into using the method BIGAL suggested for finding intersections but that would take me some time to implement.

 

Let me know if version 2.1 is sufficient.

 

~Lee

FindPoly-v2.1.lsp

Link to comment
Share on other sites

Now it's perfect! :)

 

I've done already a very large area with the zoom out trick, in a little more than an hour, it would have taken me ages manually. Now using the fixed version

 

Thanks again, I really appreciate your time. I wish I could return the favour. For someone with "limited lisp experience" I'd say this is really good!

Link to comment
Share on other sites

rdp,

 

I'm glad it is working for you. It was much more fun for me than working on my taxes.

 

When I first dabbled with AutoLISP I used a book to learn and a lot of trial and error. Now that we have google it makes getting answers to programming questions much easier.

 

I've made one more tweak (v2.2) that turns off all the extraneous output.

 

Enjoy!

 

Lee

FindPoly-v2.2.lsp

Link to comment
Share on other sites

  • 2 years later...

hi..this might be a very late respons but i think it helps

there is an other easy way to do that by using mapinfo programme

convert both text and polyline lyers then create a table in both of them

update the collums then using the query you can give every pline a spesific color

convert it back to Autocad then use Qselect

done

Link to comment
Share on other sites

  • 2 years later...

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...