Jump to content

Ignore zoom level


steven-g

Recommended Posts

How do you get Autocad to ignore the zoom level when running code. I am trying to select pairs of related objects (door block and door number) which are located close to each other, using a list of the block insert coordinates and then using a crossing window to select the associated text, the code checks only 2 items are selected then moves them to another area of the drawing, if too many items are selected (too close together - or possibly duplicated overlapping objects) or only one item is selected (text is too far away - or a door without a number) then these are left in place, so I can then look at possible problems.

This works fine in testing a small area, but when working on a larger area (zoomed out) it fails in a lot of cases, I have osnaps turned off and "pickbox = 0" what other variables determine how a selection area is calculated, I only want the items that are within the points calculated for a crossing box. I can add a zoom into the code for each selection but this slows things down to a crawl and having the screen jumping all over seems a bit silly when the actual mathematics is correct.

Link to comment
Share on other sites

If I have followed that code correctly it creates two lists and then looks to see how far every text item is away from each polyline, which must be thousands of loops, it works flawlessly and quickly. But wouldn't it be far less work to select text items that are within a selection area for each polyline, or is my logic flawed, it is possible that the background program code takes far more computer power to see what items are captured by a crossing window each time than it does just to create two lists of all the relevant objects properties once and then repeatedly comparing those ever diminishing lists. The code I am using works fine and also quickly, it just fails when zoomed out too far as too many objects are being selected by the selection method, it's the zooming into each area every time that is slowing things down.

 

Are there any references for checking speeds of code segments to find bottlenecks and compare different approaches.

Link to comment
Share on other sites

45 minutes ago, steven-g said:

Are there any references for checking speeds of code segments to find bottlenecks and compare different approaches.

You can start with THIS.

 

From my experience. point selections are unreliable.

Edited by ronjonp
Link to comment
Share on other sites

@steven-g

Your analysis is not entirely correct. If a sub in the 2nd foreach loop passes the 'if' test, it is removed from the restLst variable. Resulting in a faster execution time the next time this foreach loop is entered. In your situation the speed can be further improved by using vl-some instead of foreach.

Edited by Roy_043
Link to comment
Share on other sites

Yeah I got that bit which is why I mentioned ever diminishing lists, and yes I do need to learn more about the visual lisp side of things, I'm only up to the very basics at the moment but I'm impressed with the possibilities, but I'm sure I'm still missing something on this one, probably just me thinking more about the methods used in a GUI when I should be thinking more about Database inquiries.

Link to comment
Share on other sites

44 minutes ago, Roy_043 said:

In your situation the speed can be further improved by using vl-some instead of foreach.

Agreed .. in addition the total selection could be sorted by X values so vl-some should find the closest text faster .. remove the text from the list .. then on to next block.

Link to comment
Share on other sites

The quick and dirty is to use zoom c scale this allows a quick zoom in to a point at fixed scalE 

 

This is a known bug for as long as I can remember when using lisp.

Edited by BIGAL
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...