Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trying to rename entire pipe network from excel

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
ruipfbarreiros
478 Views, 3 Replies

Trying to rename entire pipe network from excel

Hi,

 

I'm trying to rename my pipe network using excel. So far i've come to this piece of code:

 

Dim handle As String
    i = 2
    handle = sheetStructures.Cells(i, 1).Value
    Do
    
        Set obj = ThisDrawing.HandleToObject(handle)
        Set struct = obj

        struct.Name = sheetStructures.Cells(i, 2).Value
        
        i = i + 1
        handle = sheetStructures.Cells(i, 1).Value
    Loop While handle <> ""

 

The problem is that the code suddenly stops after this instruction: 

 

struct.Name = sheetStructures.Cells(i, 2).Value

 

it works fine for the first structure, but then it suddenly stops, as if I had coded "Exit"...

 

do you know what's happening?

 

Thanks

 

---------------------------------------

Using Building Design Suite 2019
3 REPLIES 3
Message 2 of 4

can you help?

 

should have posted this in the customization forum...sorry about that

---------------------------------------

Using Building Design Suite 2019
Message 3 of 4
Jeff_M
in reply to: ruipfbarreiros

Post in the other forum and maybe include a sample excel file, full code, & dwg to test with. Although it looks like you are using VBA, and I'm not sure there a very many people who have installed the VBA enabler (I know I haven't since it slows down 64 bit installs).

Jeff_M, also a frequent Swamper
EESignature
Message 4 of 4
ruipfbarreiros
in reply to: Jeff_M

i figured it out!

 

the problem was that as the code loops through the different structures, it renames those structures one by one, meaning that when it tries to rename structure #45 to #46 for example and structure #46 already exists, it fails no rename so that the two structures don't have the same name, and it quits the code without warning.

 

The solution is to rename the structures from the bottom up, that is to say, from the highest to the lowest number so that the situation described above doesn't happen!

 

Thank you anyway

---------------------------------------

Using Building Design Suite 2019

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report