steven-g Posted December 20, 2018 Share Posted December 20, 2018 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. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 20, 2018 Share Posted December 20, 2018 (edited) You can do something like this: https://www.cadtutor.net/forum/topic/65390-scaling-text-and-objects-question/?do=findComment&comment=538842 Edited December 20, 2018 by Roy_043 Quote Link to comment Share on other sites More sharing options...
steven-g Posted December 20, 2018 Author Share Posted December 20, 2018 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. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted December 20, 2018 Share Posted December 20, 2018 (edited) 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 December 20, 2018 by ronjonp Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 20, 2018 Share Posted December 20, 2018 (edited) @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 December 20, 2018 by Roy_043 Quote Link to comment Share on other sites More sharing options...
steven-g Posted December 20, 2018 Author Share Posted December 20, 2018 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. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted December 20, 2018 Share Posted December 20, 2018 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. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 22, 2018 Share Posted December 22, 2018 (edited) 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 December 22, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.