Jump to content

Saving a list of attributes with drawing


meracl

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

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