LISP add-on - need to assign sequential ID # to attributes

LISP add-on - need to assign sequential ID # to attributes

Anonymous
Not applicable
7,271 Views
58 Replies
Message 1 of 59

LISP add-on - need to assign sequential ID # to attributes

Anonymous
Not applicable

I have this awesome LISP from @dlanorh, and now need some new functionality added. Maybe the original creator can help me out? 🙂

 

In addition to what the LISP already does (calculating the sq ft and entering it in the attribute "Area ="), I would like to assign each polyline a unique ID # in one of the other attributes in that same block. The block is "RoomTagArea" and the attribute is "ID:". (Polylines and blocks are on the same layer.) The unique number would have the prefix "SM" followed by 6-digits starting at "000001". So the end result would look like "ID: SM000001", "ID: SM000002", "ID: SM000003", and so on for the blocks found within each polyline. Is this possible?

 

I've attached the original LISP and a screenshot of what the blocks should look like after running the LISP. Thanks!

0 Likes
Accepted solutions (3)
7,272 Views
58 Replies
Replies (58)
Message 2 of 59

dlanorh
Advisor
Advisor

Please post a drawing containing the new room block (Autocad 2010). Does the Poly ID also require exporting to the csv file?

I am not one of the robots you're looking for

0 Likes
Message 3 of 59

Anonymous
Not applicable

The unique ID can be in the spreadsheet if that's easy to add. If not, that's ok. Here's the DWG. 😄

0 Likes
Message 4 of 59

dlanorh
Advisor
Advisor
Accepted solution

Attached is the updated and tested lisp.

 

Points to note:

 

1. I have updated the block to search for name to reflect the block name in the supplied drawing.

 

2. Since there are NO Room numbers, but names, the rooms are sorted alphabetically in the CSV file.

 

3. Polyline ID's are written to CSV file.

 

4. As point 2 above re Room No's; the Polyline ID's are assigned as in the order processed. I was hoping to assign polyline ID 1 to Room No 1, but the change to names negates that .

 

I am not one of the robots you're looking for

0 Likes
Message 5 of 59

Anonymous
Not applicable

This LISP is perfect! It does exactly what I need it to do. You are a genius! I feel like I need to send you some cookies or something, haha! Smiley LOL

 

Question: If I need to change the starting number of the ID # for the next drawing to pick up where it left off, where would I do that within the LISP? I may need to do this if I need unique ID's for rooms on several floors of one building.

 

Also, not very crucial, but how do I add the Room attribute "#:" to the CSV file?

 

Thank you again! You are THE BEST!

0 Likes
Message 6 of 59

dlanorh
Advisor
Advisor
Minor changes will be needed to set the starting ID: Number. i will sort this and the room attribute. No more than an hour.

I am not one of the robots you're looking for

0 Likes
Message 7 of 59

dlanorh
Advisor
Advisor
Accepted solution

OK, Attached is tweaked lisp (not tested) as I am away from a full version of AutoCAD.

I am not one of the robots you're looking for

Message 8 of 59

Anonymous
Not applicable

Works fabulously! Thank you! When the LISP ends, it says "nil" in the command line. Do you know why that would be? It seems to be working regardless, just curious.

0 Likes
Message 9 of 59

dlanorh
Advisor
Advisor

It is the return from the last line in the lisp

 

  (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark c_doc))
);end_defun

This line checks to see if there is an open undo mark, and if there is it closes it.

 

If you want to supress it alter to

 

  (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark c_doc))
  (princ)
);end_defun

 

 

I am not one of the robots you're looking for

0 Likes
Message 10 of 59

Anonymous
Not applicable

Perfect! Works like a charm. Thanks again!

0 Likes
Message 11 of 59

Anonymous
Not applicable

This might be a long shot, but I have an additional request. After we outline all of the spaces in a building with plines, we would like a way to check to make sure we didn't miss any spaces. Is there a way to hatch all of the plines spaces when the LISP runs? The hatching would need to be created on a new layer just for the hatch, so it can be turned off after the visual inspection. Or would this need to be a separate LISP? Thank you for all your help thus far!

0 Likes
Message 12 of 59

dlanorh
Advisor
Advisor
Iwill be returning to work tomorrow and will take a look.

I am not one of the robots you're looking for

0 Likes
Message 13 of 59

Anonymous
Not applicable

Apologies if this has already been addressed.

If you wanted to do this with a separate lisp he's one I quickly wrote up (attached). I wrote this under the assumption that your room border plines are all on a layer that doesn't have any plines on it that you don't want hatched. The lisp file will need to be modified to have that layer name in the code (the variable for that layer name is plinelayername and there is a comment next to it explaining where to put the actual layer name). Similarly you can choose the name of the layer you want the hatches to be on in a similar fashion.

The routine will apply a separate solid hatch to each of the plines on the pline layer, and the hatch layer will be nonplottable so if it is left on accidentally after checking it won't affect any plots you perform. But after checking I'd recommend simply freezing the layer or deleting everything on it.

I've left plenty of comments so hopefully the routine is easy to read, understand, and modify. Hope this helps.

0 Likes
Message 14 of 59

dlanorh
Advisor
Advisor
Accepted solution

@Anonymous wrote:

This might be a long shot, but I have an additional request. After we outline all of the spaces in a building with plines, we would like a way to check to make sure we didn't miss any spaces. Is there a way to hatch all of the plines spaces when the LISP runs? The hatching would need to be created on a new layer just for the hatch, so it can be turned off after the visual inspection. Or would this need to be a separate LISP? Thank you for all your help thus far!


 

I've tried to incorporate this into the Room Areas lisp but it leaves the drawing looking a mess. I have thus made it a seperate lisp which is attached

 

The second setq group is the area where you can change the hatch layer name, hatch type and pattern scale. If you set a pattern scale with "SOLID" hatch type the scale will be reset to 1.0. If the hatch layer name doesn't exist it will be created and a basic color dialog will pop up so that you can select the new layers color.

 

The lisp will only select closed polylines on the selected polyline layer. All hatches will be placed on the hatch layer, color : bylayer with the set patternscale.

 

 

 

 

 

I am not one of the robots you're looking for

0 Likes
Message 15 of 59

Anonymous
Not applicable

The check polylines hatch lisp works great! Thank you!

 

Concerning the original lisp that assigns unique numbers to each polyline... I've discovered that if I add new spaces to the floor plan, and re-run the lisp, it renumbers all the spaces, starting with the most recently drawn polyline. Is there a way to make it skip polylines that already have a value in the attribute? I do not want the numbers reordered every time I run the lisp. Once a number is assigned to a space, I need it to remain. Any help would be appreciated!

0 Likes
Message 16 of 59

dlanorh
Advisor
Advisor
Time is tight at the moment. Will look at it later in the week.

I am not one of the robots you're looking for

0 Likes
Message 17 of 59

Anonymous
Not applicable

Greetings! I have a question about the LISP. Sometimes I've double checked that all the polylines are "closed", and that they do indeed have block tags in them, but for some reason, the LISP will not process all of them. I've found that if I redraw the "offending" polylines, then it will process correctly. Curious, what causes a polyline to be skipped when the LISP runs? And is there a work around?

 

Also, wondering if you were ever able to look at changing the numbering sequence to be oldest polyline first? I so appreciate any help you can continue to offer on this wonderful LISP!

0 Likes
Message 18 of 59

dlanorh
Advisor
Advisor

Hi Becky,

Firstly apologies as I haven't sorted out your previous request. I will make this a priority.

 

As to why LWPolylines are not processed;  I cannot see any reason, code wise, why that would happen; unless they are not being picked up by the ssget function. This can happen if the polyline looks closed, i.e. its start point and end point have the same coordinate (drawn closed), but this doesn't set the polyline closed property and consequently it is considered an open polyline and will fail one of the ssget filters. This can be mitigated by omitting the "closed" filter check and testing each polyline individually for either case.

I am not one of the robots you're looking for

0 Likes
Message 19 of 59

dlanorh
Advisor
Advisor

Can you remind me of your workflow but posting a sample drawing of the "RoomTagArea" block state before and after running the lisp.

 

I think the lisp needs a re-write as it would be more efficient to collect all the "RoomTagArea" blocks in one go and then pair block and polyline. This would allow polylines and blocks already processed to be eliminated from the set and also enable the highest room ID already assigned to be found, allowing the next new to continue the sequence.

I am not one of the robots you're looking for

Message 20 of 59

Anonymous
Not applicable

Sure thing! Test drawing attached below! Thank you!

 

Your line of thought makes perfect sense, i.e. having the LISP ignore tags that have already been filled in with the sequential number, and picking up where it left off with any new polylines... I would like it to still recalculate the square footage each time I run the LISP, because the existing polylines sometimes get altered and need the sq ft to update.

 

NOTE: I have discovered in my experimentation that polylines that have any 0 length segments... ex: two vertices overlapping within the polyline... get ignored by the LISP even if they contain a block tag. When I remove the 0 length segment(s) by redrawing the polyline, it then processes correctly. Interesting...   Thoughts?

0 Likes