Jump to content

Add street name and adress number to existing block attributes


verb222

Recommended Posts

Hi,

I need advice/idea.

I have uploaded example1.dwg

It's easiest way to explain what I need advice for.

My job is to design cables. Data that I need to put in drawing are cable_number and connection_number and I have way doing those. But...

 

Later, I also need show that data in excel table like attached. I plan to do it via Export Attribute Information.

 

Now, imagine whole town, lots of different street names, house numbers.

I need advice how to put easily those data from existing landbase drawing (street name, house number) into block because no other way of making xls table doesn't come to my mind.

 

Maybe it can be done using some GIS program, it is an option if somebody convince me it is possible - I'll learn it.

Maybe it can be done via some lisp, routine... (programing of those is chinese language for me :) )

 

Manual way of doing the table would be BLOCK without street names and house numbers, just cable data... AND... opening excel and putting data by typing.

 

I would appreciate advice/idea how to do it easiest way.

 

Tnx for giving it a thought.

Example1.xlsx

Example1.dwg

Link to comment
Share on other sites

Pretty easy need some time, enter cable number, pick st name, Repeat -> pick house no, place block. Other alternative is place block lots of them first, line up nicely etc then Repeat -> pick house no, pick block.

 

Suns out I am going fishing.

Link to comment
Share on other sites

This is so close it has an error some where some days you just can not see it. Matches Example dwg.

 

code fixed see next post

Edited by BIGAL
Link to comment
Share on other sites

Try this

 

(vl-load-com)
(defun c:HOUSE ( / cableno stname blkobj)
(setq Connectno (Getint "\nConnection Number")) 
(setq Cableno (getstring "\nEnter Cable No"))
(setq stname (vla-get-textstring (vlax-ename->vla-object (car (entsel "\nPick Street Name")))))
(while (/= nil (setq Hnum (vla-get-textstring (vlax-ename->vla-object (car (entsel "\nSelect House number pick nothing to exit"))))))
   (setq blkobj (vlax-ename->vla-object (car (entsel "\nPick House block"))))
   (foreach att (vlax-invoke blkobj 'getattributes)
       (if (= "STREET_NAME" (vla-get-tagstring att))
       (vla-put-textstring att stname) 
       ) ; end if
       (if (= "ADDRESS_NUMBER" (vla-get-tagstring att))
       (vla-put-textstring att Hnum) 
       ) ; end if
       (if (= "CABLE_NUMBER" (vla-get-tagstring att))
       (vla-put-textstring att Cableno) 
       ) ; end if
       (if (= "CONNECTION_NUMBER" (strcase (vla-get-tagstring att)))
       (vla-put-textstring att (rtos Connectno 2 0))
       ) ; end if
    ) ; foreach
    (setq Connectno (+ 1 Connectno))
) ;while
(princ) ; exit neatly
) ; Defun
(c:house) ;for testing remove after

Link to comment
Share on other sites

BiGAL,

thank you!

 

Your's code was inspiration for further idea enhancement. From it, I've made two lisps. One inputs house number from picked text to attribute, and second one puts street name from picked text to attribute. Cable stuff attributes are unnecessary for this purpose.

I changed yours code by deleting what I was thought was excess/over. Please, don't laugh. Probably it needs some reduction, but I don't understand it too much, so I've just made it works for me, like this:

1. house number

(vl-load-com)
(defun c:Han ( / cableno stname blkobj)


(while (/= nil (setq Hnum (vla-get-textstring (vlax-ename->vla-object (car (entsel "\nSelect House number pick nothing to exit"))))))
   (setq blkobj (vlax-ename->vla-object (car (entsel "\nPick House block"))))
   (foreach att (vlax-invoke blkobj 'getattributes)
       
       (if (= "ADDRESS_NUMBER" (vla-get-tagstring att))
       (vla-put-textstring att Hnum) 
       ) ; end if
      
    ) ; foreach
   
) ;while
(princ) ; exit neatly
) ; Defun
(c:house) ;for testing remove after
Now


2. street name
Code:
(vl-load-com)
(defun c:hsn ( / cableno stname blkobj)


(while (/= nil (setq Hnum (vla-get-textstring (vlax-ename->vla-object (car (entsel "\nSelect House number pick nothing to exit"))))))
   (setq blkobj (vlax-ename->vla-object (car (entsel "\nPick House block"))))
   (foreach att (vlax-invoke blkobj 'getattributes)
       
       (if (= "STREET_NAME" (vla-get-tagstring att))
       (vla-put-textstring att Hnum) 
       ) ; end if
      
    ) ; foreach
   
) ;while
(princ) ; exit neatly
) ; Defun
(c:house) ;for testing remove after

 

Please, can you do one more thing for me. Make second code (street address) to work like this:

First I pick text with street name, and than that command keeps executing in the way I dont need any more to choose source input for street name - just to be able paste it in more then one block attributes. Something similar how MATCH PROPERTIES works. You pick source, and all clicks after that are "pasteing" the same properties to different objects (blocks in this case).

 

Once again, tnx!

Edited by SLW210
Added Code Tags.
Link to comment
Share on other sites

Hi, I did it. I put WHILE loop and it works.

It was quite long reading about LISPing, but I made something work... even it was changing someone else's code, but... I am happy :)

I must confess, it was very motivating for future learning about LISPing. Hope it'll be time for that. Once again, tnx.

Link to comment
Share on other sites

No worries, changing a block attribute is relatively simple. There is a second method in that you just use the attribute creation order att1 att2 etc and change the required one so dont need to worry about attribute name. Ps use the code tags next time thats the # option or the administrator will be after you.

Link to comment
Share on other sites

Sorry, i thought "Code:" works like "#". Sorry!

 

;just wanna try it 

 

I have problem now: I realized possibilities with programming/combining LISPs. Now I am spending hours learning, browsing, reading... Luckily, I am on vacation :)

Link to comment
Share on other sites

[ c o d e ] and [/ c o d e ] without spaces

 

Re vacation started in 1980's with lisp. But others are just so brilliant, leaning all the time.

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