Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Extract attributes from blocks intersected by a polyline

luigiverdenico
Enthusiast

Extract attributes from blocks intersected by a polyline

luigiverdenico
Enthusiast
Enthusiast

Hi all,

I explain you my necessity. I drew cable ways in a plant design as blocks with attributes. In particular every cable way has a code (example: TM001NA, TM002NA, ecc.). Now I have to do the cables routing: an excel document where I write the path of every cable as serie of cable ways codes cross by the cable.

So if a draw a polyline that simulates the path of a generic cable from the start point to the end point through the cable ways, is there a way in autocad to join the codes of cable ways intersected by this polyline and export the result? (example: TM001NA_TM002NA_ecc.).

Thank you for the attention.

0 Me gusta
Responder
Soluciones aceptadas (1)
1.521 Vistas
18 Respuestas
Respuestas (18)

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

AutoCAD itself does not have an option to evaluate a list of blocks along a polyline.

You need to use either GIS-Tools (topology, could be done with Map3D, Civil3D) or you need to find or write a small app that does that for you.

 

Can you show such a dwg-file (small part, just to see a sample with 2 or 3 polylines and their block-insertions), let us know which version of AutoCAD you are using and if you have any experience with development languages like LISP, VB/A, VB.NET, C#, ....

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2025
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Me gusta

dlanorh
Advisor
Advisor

I have a lisp program that follows drainage runs (a lwpolyline) and extracts the the invert levels from the manhole blocks along its route. This sounds very similar to what you require and could be adapted to suit your need.

 

1. Are you running full AutoCAD or AutoCAD LT?

 

2. I would need a drawing containing the block you use, so that I can determine the block tags. If you could supply this in AutoCAD 2010 format.

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

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast

Hi,

i use a full AutoCAD version.

I attach an example.

Thank you very much for the help.

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast

Hi,

i dont have any experience with development languages like LISP, VB/A, VB.NET, C#.

Here is a little example of my necessity.

Thank you

0 Me gusta

dlanorh
Advisor
Advisor
I may need some further guidance, so check back regularily

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

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast

ok

0 Me gusta

dlanorh
Advisor
Advisor

Not as I anticipated from your initial post.


Attached is a preliminary lisp file and a modifyed example drawing. The lisp file has two lisps and associated functions within.


Download both and save to a location of your choice.


Open "example" drawing. I have modified this drawing to contain an extra block "pmark" and added an extra cable run with color 190.


Load the lisp file by typing appload on the command line. When the dialog appears, navigate to where you saved the lisp file, left click on it to select the press the load button then the close button.


Both lisps are set up to allow the selection of multiple lwpolylines, and will then process all the polylines. At present they both ask for an insertion point and display the "routes" as an Mtext object. I will insert the code to write this to an excel file when i have all the correct information. Do you have a layout for the excel sheet in mind?

 

Lisp : Test1. Type test1 on the command line. This will ask you to select all the polylines you want to process.

It will then ask for an insertion point and used that to insert the text. This distinguishes the polylines by color.


Lisp : Test2. Type test2 on the command line. This will ask you to select all the polylines you want to process. It inserts a marker block at the start and end of the polyline which containing a number. It will then ask for an insertion point and used that to insert the text. This distinguishes the polylines by marker number.


I notice that all your polylines are on layer "0". Is this always the case? The current code extracts the layer and color of each polyline, so this information could be included as could the polyline length.


Which do you prefer, or do you have something else in mind?

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

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast

First of all I thank you for your availability and for your work.

The document excel is a format given from the client company.

In reality in my design I dont have to draw the cables, so polyline is just a work item that I use to identify the path and the length of the cable to report in the Excel. The cables are very numerous, so for the generic cable I draw the polyline on dwg, write the cable routing on excel, erase the polyline and proceed with the next cable.

For that reasons I ask you if it is possible modify lisp so that when I select the polyline, click the right button of mouse, select a command associated to lisp, cable routing is elaborated (without the indication of color of polyline, just the serie of ID) and memorized in Windows clipboard (then I will paste it manually in excel document).

Is it possible to use as separator between the codes the symbol "_" instead "-"?

Thank you very much.

0 Me gusta

dlanorh
Advisor
Advisor

@luigiverdenico wrote:
In reality in my design I dont have to draw the cables, so polyline is just a work item that I use to identify the path and the length of the cable to report in the Excel. The cables are very numerous, so for the generic cable I draw the polyline on dwg, write the cable routing on excel, erase the polyline and proceed with the next cable.

For that reasons I ask you if it is possible modify lisp so that when I select the polyline, click the right button of mouse, select a command associated to lisp, cable routing is elaborated (without the indication of color of polyline, just the serie of ID) and memorized in Windows clipboard (then I will paste it manually in excel document).

Is it possible to use as separator between the codes the symbol "_" instead "-"?

Thank you very much.


Yes, it is possible to write just the routing out polyline by polyline, and using "_" instead of "-". I have never written anything to the clipboard but i will research if this is possible using lisp.

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

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast


Yes, it is possible to write just the routing out polyline by polyline, and using "_" instead of "-". I have never written anything to the clipboard but i will research if this is possible using lisp.


if this is not possible, can you make appear the cable routing in the autocad command line (so i can copy it more easily than the mtext object?)

0 Me gusta

dlanorh
Advisor
Advisor

Attached is a small test Lisp to test the copy to clipboard function. You can test it in a blank drawing and notepad

 

Save the Lisp and load it as previously. Type test to start the lisp. You will be prompted to enter a string. Enter a memorable string and press enter. The lisp should now display "text copied to clipboard" on the command line.

 

Move to notepad, click on a blank line, right click and select paste. The previously entered text should now be pasted into notepad.

 

Does this work? The reason I ask is that there may be a problem using this from Windows 8 onward. I cannot test it myself under Windows 8, 8.1 or 10 as I am still working with Windows 7.

 

If this works I should have a working updated lisp sometime tomorrow afternoon (my time)

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

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast

I am using Windows 10 and it works.


@dlanorh wrote:

Attached is a small test Lisp to test the copy to clipboard function. You can test it in a blank drawing and notepad

 

Save the Lisp and load it as previously. Type test to start the lisp. You will be prompted to enter a string. Enter a memorable string and press enter. The lisp should now display "text copied to clipboard" on the command line.

 

Move to notepad, click on a blank line, right click and select paste. The previously entered text should now be pasted into notepad.

 

Does this work? The reason I ask is that there may be a problem using this from Windows 8 onward. I cannot test it myself under Windows 8, 8.1 or 10 as I am still working with Windows 7.

 

If this works I should have a working updated lisp sometime tomorrow afternoon (my time)


 

0 Me gusta

dlanorh
Advisor
Advisor
Solución aceptada

Attached is updated lisp. I have renamed the main lisp routine so type GCR on the command line to run it. Enjoy.

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

luigiverdenico
Enthusiast
Enthusiast

it was just what I was looking for. Thank you very much. :cara_con_una_leve_sonrisa:

Can i ask you one last favor? Can you create a similar lisp for the block attached? (named "tubo" instead "canalina")

0 Me gusta

dlanorh
Advisor
Advisor
Is it used in similar circumstances? Post an example drawing using the "Tubo" block as you did with the "canalina" block.
If it is used in the same way I might be able to use the same lisp for both blocks, where you are asked which block to use. This can be achieved using dynamic input methods so you click on the choice with the mouse with the default choice marked, so by right clicking the default is chosen. I cannot start this until tomorrow mid afternoon my time (European).

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

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast

Hi,

I post you a file complete where there are all blocks that i identify with attribute ID:

- canalina

- tubo

- canalina sezionata (i forgot it yesterday)

I wrote the routing associated tothe yellow polyline. Can modify your lisp so that it can manage all 3 blocks at the same time and provide the complete routing?

0 Me gusta

dlanorh
Advisor
Advisor

Attached is version 2 of the Lisp. Your request took about 5 mins so I completed it before going to work.

This will handle the 3 blocks you requested.

 

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

0 Me gusta

luigiverdenico
Enthusiast
Enthusiast

Perfect, thank you very much

:cara_que_ríe_con_la_boca_abierta_y_los_ojos_sonrientes:

0 Me gusta