Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
i have found the following lisp in a previous thread: (shows XY coordinates of the selected blocks)
(defun C:MyFunc (/ ss Index Ename Lst)
(while (or (not ss) (= 0 (sslength ss))) (setq ss (ssget '((0 .
"INSERT")))))
(if ss
(progn
(setq Index 0)
(repeat (sslength ss)
(setq Ename (ssname ss Index)
Lst (append (list (cdr (assoc 10 (entget Ename)))) Lst)
Index (1+ Index)
)
)
(foreach item Lst (terpri) (princ item))
)
)
(princ)
)
i want this information to be added to the blocks as hidden attributes so that i can extract them by attout.
is it possible?
any other suggestions would be greatly appreciated. the work to be done is : attout to excel, autofill an attribute (numbering) then attin.
but my problem is that i cant think of a way to number those blocks IN ORDER (ie top to bottom or left to right) unless by sorting them in excel first by their x or y coordinates
Solved! Go to Solution.
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
vahe.holtian wrote:
.....i want this information to be added to the blocks as hidden attributes so that i can extract them by attout.
is it possible?
any other suggestions would be greatly appreciated. the work to be done is : attout to excel, autofill an attribute (numbering) then attin.
but my problem is that i cant think of a way to number those blocks IN ORDER (ie top to bottom or left to right) unless by sorting them in excel first by their x or y coordinates
Are you wanting to select from a list of blocks or ALL?
Do you have an existing block with invisible attributes?
To sort the blocks look into this link BlockSSSort.lsp by Kent Cooper <-- post # 9 [kudos to Kent]
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
after reading the suggested page for hours im completely lost.
it seems to be what i need but i cant figure out the rest. what is blockSSSort.lsp doing?
i want to select many blocks and increment the value of 1 of its attributes but the increment should have a prefix and a 4 4 digit format so i thought just adding the X coordinates as hidden attributes (to be created) and doing the job in excel would be easier
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
vahe.holtian wrote:
it seems to be what i need but i cant figure out the rest. what is blockSSSort.lsp doing?
...... but my problem is that i cant think of a way to number those blocks IN ORDER (ie top to bottom or left to right) unless by sorting them in excel first by their x or y coordinates....
BlockSSSort.lsp will sort the blocks in order so that you can number the blocks Top to Bottom or Left to Right
vahe.holtian wrote:
i want to select many blocks and increment the value of 1 of its attributes but the increment should have a prefix and a 4 4 digit format so i thought just adding the X coordinates as hidden attributes (to be created) and doing the job in excel would be easier
You mean create a block with invisible attributes on the existing blocks to contain the X and Y coordinates for tthe sole purpose of sorting the blocks?
Hence the function BlockSSSort.lsp so you can make do without creating the invisible attributes.
But then again you would be using DATA EXTRACTION. I beleive you can sort the output via dialog box
Knowing that now, do you still need to add the invisible attribute and number the blocks ?
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
What is BlockSSSort.lsp doing? Im trying (BSSS "t" "l") but what is the result?
(also, dataextraction is not convienient to me because I need to change those values based on an increment system ie A098, A145, A832, B134, B009 should become A001,A002,A003,B001,B002 based on their position)
Please can you guide me a bit further regarding the BlockSSSort.lsp?
Thank you for ur assistance!
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
vahe.holtian wrote:
I wanted to create a new hidden attribute value containing the x coordinate of the block. ....
What is BlockSSSort.lsp doing? Im trying (BSSS "t" "l") but what is the result?
....
That routine simply sorts selected Blocks in positional order, in the positional directions that the User specifies in the arguments to the function, and returns a list of Block-insertion entity names in that sorted order, as well as saving that list into a variable. It doesn't do anything like add an Attribute to the Blocks, but I suppose it could be used as a starting point to do so, if you want something about that Attribute to be incremented in positional order. If you need an Attribute only to indicate the X or X & Y coordinate(s), that doesn't sound like any kind of positional sorting would be required. But if the only reason for the Attribute is to feed information out to something that will sort, this can spare you that middle-man. If all you need to sort by is X coordinate as quoted above, rather by X and Y coordinate as in some earlier messages, that could be done a lot more simply than with BlockSSSort.lsp -- a much simplified version of it would do.
Also, are these Blocks that already have an Attribute for whatever you want to put in it, and it's only a matter of getting the value into it? Or will an Attribute need to be added to the Block definition(s)? Are they always going to be insertions of the same Block, or different Blocks?
I think a before-and-after sample drawing, or a sample drawing and a sample file of whatever the ultimate output would be, would clarify what you're trying to do.
EDIT: Looking back, I noticed one line I hadn't caught before:
"...i want to select many blocks and increment the value of 1 of its attributes but the increment should have a prefix and a 4 4 digit format...."
If that prefix is the sort order integer, and the 4 4 digit format are the X and Y coordinates, and the Attribute already exists, that sounds reasonably doable with BSSS as a start. Is that what you're after?
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
i uploaded a sample drawing.
the whole point is getting those values (A001,A002,A003,B001,B002,S001....) numbered correctly and in the same format and in a way that when a person takes the drawing he can follow some path to read through all of them in a neat way, just not scrambled.
many thanks to you!
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
vahe.holtian wrote:....
the whole point is getting those values (A001,A002,A003,B001,B002,S001....) numbered correctly and in the same format and in a way that when a person takes the drawing he can follow some path to read through all of them in a neat way, just not scrambled.
....
It appears that all Blocks with BAR_MARK Attribute values beginning with A are of the same Block name, and all those beginning with B are of the same other block name, but those beginning with S are of various Block names. So it looks like a routine wouldn't be able to just positionally sort all the insertions each Block name separately, because you'd end up with [for example] more than one S001. But if those values already exist in their scrambled order and with initial letters that are to remain, a routine could certainly be made to read the first letter of that Attribute value, put each Block into a list of those that share that first letter, positionally sort each of those lists [apparently, in this example, using the "L" and "T" options in BSSS -- would you always want them sorted in the same way?], and replace the numerical portion of that Attribute value in each Block of each list with a positionally-sequential number. It wouldn't require exporting anything or doing the sorting in an external program. Does that sound like what you're after?
Re: Add attribute to selected blocks (XY coordinate s)
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
vahe.holtian wrote:i uploaded a sample drawing.
the whole point is getting those values (A001,A002,A003,B001,B002,S001....) numbered correctly and in the same format and in a way that when a person takes the drawing he can follow some path to read through all of them in a neat way, just not scrambled.
many thanks to you!
Same queries as Kents vahe.holtian, I think its doable,
Why did you end up with those block names anyway?



