AutoLISP code to draw a heating cable layout in a selected object

AutoLISP code to draw a heating cable layout in a selected object

vipul_mandloi2021
Participant Participant
1,061 Views
23 Replies
Message 1 of 24

AutoLISP code to draw a heating cable layout in a selected object

vipul_mandloi2021
Participant
Participant

I have tried to make an AutoLISP code that will create a Heating Cable layout inside a selected closed polygon.
I am not able to debug the code properly and not able to generate results.
Can anyone help me with this. 
I have attached the code.

0 Likes
1,062 Views
23 Replies
Replies (23)
Message 2 of 24

devitg
Advisor
Advisor

@vipul_mandloi2021 . please upload your sample.dwg and the way you want to do.

0 Likes
Message 3 of 24

vipul_mandloi2021
Participant
Participant

I have uploaded the sample.dwg below.
I want the code to respect the rules that I want and generate the layout inside a closed polygon.
The given sample is very densed with a lot of annotations depicting the nearby areas., I need the script to generate just the layout inside the main area (a closed polygon)

0 Likes
Message 4 of 24

Sea-Haven
Mentor
Mentor

Did you google the task ? It has been asked before, with a few people posting various solutions, one of those may meet your requirements. 

SeaHaven_0-1740796616411.png

 

0 Likes
Message 5 of 24

vipul_mandloi2021
Participant
Participant

I did google the solution for this task, but all of them were mostly laying out a single cable in a polygon.
My task was a bit more complicated,

1. I wanted that I can lay 'n' number of cables in ANY closed polygons, from single junction point.
2. Also, the cables should respect the spacing of other cables, leave area for other cables to be laid out by first reaching the least important area (mostly the farthest one).
3. The cable is to be laid in a 'Mesh' in the regular areas, while the cable can detach from the mesh to reach the irregular areas. (Refer the sample.dwg for reference)

I do appreciate your help for the task, Thanks a lot.
Just in case, if you have ever come across any AutoLISP script that includes all the mentioned points (or even some of them), please reply a link to that content for me in this post. Your assistance would be highly valued.

0 Likes
Message 6 of 24

Moshe-A
Mentor
Mentor

@vipul_mandloi2021 hi,

 

i review the lisp and found the spot where the error occur, give a little fix and what it did is one semi circle, are you sure this lisp gives you what you after? i zoomed in and see parallel lines plus disconnected lines, why it is not clean?

 

1. How about creating hatch style?

2. How about using array?

 

any way of above options manual editing must be done.

 

Moshe

 

0 Likes
Message 7 of 24

vipul_mandloi2021
Participant
Participant

Hi Moshe, 
The lisp I tried to create was a very initial step towards the goal without a significant amount of prior knowledge in the field. I am gradually learning more AutoLISP and AutoCAD things. The lisp was formerly created using Text-based AI's.
I also googled the available solutions to the related tasks but none of them included the major functionalities that I needed.
I have already mentioned the functionalities that I need in the lisp in my previous replies.

Using hatch styles can be effective in managing the 'mesh' part of the cable layout generation, but if we use this case, I am not aware of the process to deal with the part where the cable is detached from the mesh to reach irregular areas in the polygon.
Also, What will be the best use of arrays in the lisp?


I'm very appreciative of all the ideas you've given me. If it would be possible for you to demonstrate your ideas by adding your suggested functionality in the lisp and replying that file into the chat for me to test it, would be greatly appreciated.

Vipul

0 Likes
Message 8 of 24

vipul_mandloi2021
Participant
Participant

Hi Moshe,
Also, I understood the part where you are saying that the lines are disconnected in the sample file.
Actually I imported that from a PDF file and the encoding of PDF made the lines disconnected. In the actual .dwg file all the lines are connected.


Vipul

0 Likes
Message 9 of 24

Moshe-A
Mentor
Mentor

@vipul_mandloi2021  hi,

 

I gave a huge thought about that and here is the results:

What you had in mind is very complicate to achieve with AutoLISP, i do not want to say impossible but it is close 😀

so for the time been i think you should concentrate on the tools AutoCAD has to offer.

 

with HATCH

hatch language\code does not allow full arcs but a chain of small lines. if you can satisfy with that, i think this is the best solution although it is not easy to code. if arcs is must, hatch is not solution.

 

with ARRAY command

you could draw the 'coil' and array it. to do it in an angle use SNAP rotate  or set a UCS.

 

with dynamic block

you can set controls for length + width of the 'coil' plus controls for the array and angle.

 

in any of this solutions you still have to a lot of manual editing.

 

Moshe

 

0 Likes
Message 10 of 24

Sea-Haven
Mentor
Mentor

The pattern, can be created with a pline you would say enter spacing and the height. Using Ucs to twist the drafting direction should draw on angle, you would have to run multiple times but it would be faster than manually doing it. 

 

 

SeaHaven_0-1740952894224.png

Another way may be as suggested use the array function and overdraw the heating then use a trim based on a external boundary, I have used this method for a different task. The trimming occurs without user input.

SeaHaven_1-1740953201469.png

So would a make a pline ie a single row of heating be useful ?

 

 

0 Likes
Message 11 of 24

Moshe-A
Mentor
Mentor

@vipul_mandloi2021  hi,

 

Attached is nice dynamic block (heat_coil) that has an array action.

insert the block than pick it you will see a blue grip box at the right.

pick it and drag it away 45 degrees. when you reach enough coil patterns, stop there 😀

use rotate command to reach the right angle.

explode the blocks so you can edit it

the coil is actually made of curve (chain of 3 segments, arc + line + arc) mirrored so after explode

at the edges you can delete half or the coil (can be connect more easy)

 

you can scale the block at insert and if you need other proportion of length / width, you can modify the block or create new.

 

enjoy

Moshe

 

 

 

 

 

0 Likes
Message 12 of 24

vipul_mandloi2021
Participant
Participant

Hi Moshe,
If using any of the given solutions, manual editing is still required, Then I would like to know that are there any other AutoCAD features/softwares that can help me to "Automate" this process. My major requirement is to create a script/program that works like a brain and draws a Heating Cable Layout in any given polygon of any indefinite shape.
I would be glad to know about some other software alternatives and will start researching on them too.

Vipul

0 Likes
Message 13 of 24

vipul_mandloi2021
Participant
Participant

Hello Sea-Haven,
Using single row of heating won't be much useful actually. In most parts of the heating cable layout's, use of mesh widely used beacuse of how large the surface area is. Also, use of multiple heating cable's is also a major requirement.


I do like the approach you are trying to indicate and I will give that a thought, whether that helps me to meet my requirements or not.

Vipul

0 Likes
Message 14 of 24

vipul_mandloi2021
Participant
Participant

Hello Moshe,
I have gone through your AutoCAD drawing and liked the idea of using that approach. I was thinking whether we can use a script that will use this definite block to generate layouts easily and efficiently. 

Vipul

0 Likes
Message 15 of 24

Moshe-A
Mentor
Mentor

not that i know 😩

0 Likes
Message 16 of 24

Moshe-A
Mentor
Mentor

@vipul_mandloi2021 ,

 

Here is hatch pattern (heatcoil), be flexible regarding the arcs.

 

Moshe

 

0 Likes
Message 17 of 24

Sea-Haven
Mentor
Mentor

It may be possible to get a solution for any shape, what you have to remember is that the forum answers are provided free, a programmer may offer to write code as they would be factoring in their time to work towards a solution, BUT you are then paying for that process.

 

A dynamic block would seem to be the way to go, just picking two end points then manually join. Just need a draw left draw right. Same idea as draw a PLINE with arcs. A different version of these draw plines

SeaHaven_0-1741233825342.png

 

0 Likes
Message 18 of 24

-didier-
Advisor
Advisor

Bonjour @vipul_mandloi2021 

 

This is just a beginning of response, a search track.


You can make a block of this shape. Create a lisp that will calculate intermediate points between two clicked points and enter the block at these points.

I can help you if you want…

 

Example in image:

 

2025-03-06_17-52-25.gif

 

Amicalement

 

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 19 of 24

Sea-Haven
Mentor
Mentor

@-didier- good idea, use Measure no code needed, same idea I have used making a pline, you can ask for some values like spacing and length.

0 Likes
Message 20 of 24

vipul_mandloi2021
Participant
Participant

Hello Moshe, 
I liked the idea of using HATCH patterns A LOT. It was working as a charm for me.
But I'm still figuring out these things:
1. The HATCH pattern fills the block with a single cable. I want to make it to be able to generate 'N' number of cables in the given block.
2. The HATCH pattern will not be able to figure out the part where each cable starts from a single origin point and first reaches the farthest area. After that it starts getting laid down as the HATCH pattern fills out a block.

So far, I have figured out a solution for the 1st part, we can divide the required blocks into zones first and the apply different HATCHes to them. But I am not able to figure out the second part.
If in case you have any Idea about how will be able to make that work too, please feel free to share with me. Your ideas have been very helpful and your suggestions will be deeply appreciated.

Vipul

0 Likes