meracl Posted January 31, 2013 Share Posted January 31, 2013 I have a simple block (just a point) with an attibute (a no). Is it possible to save all the numbers used with the drawing preferably using lisp? And if yes what are the ways to do that? So when i insert that block again i can retrieve the no's used and dont have any duplicates. That list of no's should be amended if a no is added/deleted. Any ideas please? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 31, 2013 Share Posted January 31, 2013 What you mean by Saving all numbers ? Quote Link to comment Share on other sites More sharing options...
meracl Posted January 31, 2013 Author Share Posted January 31, 2013 I'll try to explain that better. I insert that block into a drawing and the attribute is a number the first block is 1 then 2, 3 ,4 ,5 ,6 and so on. I omitted some and then started at 101, 102 , 103 and so on Think that like a map ... we have a boundary that has 84 points so im using the numbers from 1 to 84 then the next boundary starts from 101 to lets say 156. Now if i want to add a point to the first boundary i have to check the drawing to find what is the last number used and use the next available 85 for the first boundary .... and 157 for the second. Now imagine i already have on my drawing more than 350 points (numbers used) from 1 to 600 and that's is only the start. I thought of saving them into an external txt file and retrieving that list but im not sure if that is possible .... I have read in this forum about using "dictionary" but i have never used it ... know if that is what i need. I dont even know if saving them as a list can hold so many values/items. I hope that 's more clear to you. Thank you for your time Quote Link to comment Share on other sites More sharing options...
meracl Posted January 31, 2013 Author Share Posted January 31, 2013 By the way i have seen Lee Mac's program called Autolabel attributes and its great (thanks Lee for sharing all that code with us) but not suitable in my case as i omit numbers and dont want them renumbered. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 1, 2013 Share Posted February 1, 2013 If the blocks containing the sets of numbers reside on separate Layers for each boundary, you could easily create a program to collect a selection set of all numbers pertaining to a given boundary to determine the highest or next available number, before inserting your block to use the new number. I personally don't see a need to store the list of numbers elsewhere in the drawing file, or within an external file, since the data is already stored and available in the drawing by accessing the relevant sets of attribute values. If you were to store the data twice, you would then have the headache of ensuring the duplicate data is up-to-date & accurate should the user modify an attribute value, delete a block, undo a block deletion, copy, mirror, array a block.... I see this involving reactors with many complex callback functions to account for every possible eventuality - all just to update data which is already available and relatively easily accessible. I hope this helps steer you in the right direction! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 1, 2013 Share Posted February 1, 2013 A simple method is to just read a point block you have and just end up with the highest number then next insert is just +1 something like this (setq tag1 "SETOUT_POINT_NUMBER") ; change to your tag name (setq ptno 0) (setq ss1 (ssget "x" '((0 . "INSERT") (2 . "SETOUT_POINT_NO")))) ; change to your block name (setq x (sslength ss1)) (repeat x (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq x (1- x)) )) 'getattributes) (if (= tag1 (strcase (vla-get-tagstring att))) (PROGN (setq highnum (atoi (vla-get-textstring att))) (if (> highnum ptno) (setq ptno highnum) ) ; IF ) ; PROGN ) ; IF ) ; FOREACH ) ; REPEAT (setq ss1 nil) (princ (strcat "\nHighest ptno is " (rtos ptno))) Quote Link to comment Share on other sites More sharing options...
meracl Posted February 1, 2013 Author Share Posted February 1, 2013 Yes there are already on different layers! I was only trying to do that the hard way!!! Silly me! Thank you Lee for pointing the easyest way to do it! And thank you Bigal for the code to start with. Thank you all. Have a nice Friday or Friday evening! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 1, 2013 Share Posted February 1, 2013 No worries Friday 5:pm beer o'clock Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 1, 2013 Share Posted February 1, 2013 You're welcome meracl, have a good weekend Quote Link to comment Share on other sites More sharing options...
meracl Posted February 1, 2013 Author Share Posted February 1, 2013 Thanks Lee you too Damn i guess its already too late for that beer! 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.