LISP or Script needed to change census id's from one layer to another

LISP or Script needed to change census id's from one layer to another

Anonymous
Not applicable
1,224 Views
10 Replies
Message 1 of 11

LISP or Script needed to change census id's from one layer to another

Anonymous
Not applicable

I am looking for help on a quick way to change multiple census id's from one layer to another layer.

Could this be done by using a Lisp or simple Script or in Excel format?

0 Likes
Accepted solutions (2)
1,225 Views
10 Replies
Replies (10)
Message 2 of 11

Ranjit_Singh
Advisor
Advisor

That's seems simple enough to be accomplished using native AutoCAD commands/tools. Use Qselect to get the selection set and change layer in properties palette. Or use Change command. Wouldn't that work? If not, then explain why it's not that simple. Provide some more details, in AutoCAD terminology. For ex, are census ids mtexts or texts or blocks or ?

0 Likes
Message 3 of 11

Anonymous
Not applicable

Ranjit,

 

Thanks for the reply.  The Census Blocks have Object Data assigned to them.  I have queried the blocks to bring out the GEOID number (300959664001007)

 

I have a list of 125 Census Blocks that I need to find in a short manner of time and was looking for a fast way to do this.

 

I was thinking if there was a quick program to change the numbers to a different layer (like "temp") all in one shot if that was possible.

0 Likes
Message 4 of 11

Ranjit_Singh
Advisor
Advisor

Can you share the drawing if it has no sharing restrictions?

0 Likes
Message 5 of 11

Anonymous
Not applicable

Here is the drawing

0 Likes
Message 6 of 11

Ranjit_Singh
Advisor
Advisor

Do you have the needed geoids in a AutoCAD list format? Or are you reading it from some other file (txt, csv etc.)? or do you known a test criteria, such as, test if the geoid falls between, say, 301119400005234 and 301119400005194, then change the layer?

0 Likes
Message 7 of 11

Anonymous
Not applicable

Ranjit,

 

Here is a smaller version of that drawing.  I didn't know it was the large when I uploaded it.

0 Likes
Message 8 of 11

Anonymous
Not applicable

Ranjit,

 

Sorry I was out for most of the day.

I get the information from a excel file.

0 Likes
Message 9 of 11

Ranjit_Singh
Advisor
Advisor
Accepted solution

I am not sure how you are reading the excel file. But let's assume the data is read into a list format. I will use an example list based on the drawing you provided

(defun c:somefunc  (/ adoc geoidlist)
 (setq geoidlist '("301119400002166" "301119400002168" "301119400002165")); sample data
 (ssget "_x" '((0 . "lwpolyline")))
 (vlax-for i  (vla-get-activeselectionset (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (and (member (ade_odgetrecfield (ade_odgetrecord (vlax-vla-object->ename i) "tl_2010_30_tabblock10" 0) "GEOID10")
               geoidlist)
       (vla-put-layer i "Layer1"))); change "Layer1" to correct layer name
 (princ))

Geo_id.gif

 

0 Likes
Message 10 of 11

Anonymous
Not applicable
Accepted solution

Ranjit,

 

Thank you.  I think that will do me good.  I was wondering how many geoids can I put in before I have to change the syntax of the text?

 

(defun c:yellowstoneblocks (/ adoc geoidlist)
(setq geoidlist '(“301110014011033” “301110014012032” “301110014012053” “301110014021007” “301110014021012” “301110014021013” “301110014021040” “301110014023078” “301110014023164” “301110014023175” “301110015012001” “301110015012036” “301110015021157” “301119400001034” “301119400001095” “301119400002116” “301119400002130” “301119400002132” “301119400002136” “301119400002139” ”301119400002149” “301119400002151” “301119400002155” “301119400002156” “301119400002158” “301119400002159” “301119400002160” “301119400002162” “301119400002163” “301119400002168” “301119400002169” “301119400002170” “301119400002175” “301119400005010” “301119400005014” “301119400005023” “301119400005040” “301119400005044” “301119400005045” “301119400005060” “301119400005062” “301119400005106” “301119400005126” “301119400005130” “301119400005131” “301119400005137” “301119400005170” “301119400005184” “301119400005193” “301119400005194” “301119400005203” “301119400005206” “301119400005212” “301119400005215” “301119400005222” “301119400005226” “301119400005228” “301119400005244” “301119400005279”));
(ssget "_x" '((0 . "lwpolyline")))
(vlax-for i (vla-get-activeselectionset (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
(and (member (ade_odgetrecfield (ade_odgetrecord (vlax-vla-object->ename i) "tl_2010_30_tabblock10" 0) "GEOID10")
geoidlist)
(vla-put-layer i "temp")));
(princ))

0 Likes
Message 11 of 11

Ranjit_Singh
Advisor
Advisor

I have never seen any problem with list lengths. A quick test on my system shows lists of length 16777216 generate pretty quick. Beyond that I see system lag. Definitely not a problem for those many (as shown in above post).

0 Likes