走马观花

Hilbert curve drawing plugin

 
Overview

# Background
Recently, it is popular to use aluminum substrates to make heating plates. The most common method is to place lines in an array and then make fine adjustments. However, I have seen some players make very fancy aluminum substrates. After some research, I found that they use the Hilbert curve, which is said to be able to achieve the maximum length. If it is so awesome, then we should do it. But what should we do? If we draw by hand, we will be stupid. I saw someone use py to draw and generate json for import. I remember that LiChuang EDA said before that it supports plug-ins, so let's study plug-in generation.

PS: The official does not pay enough attention to plug-ins. The professional version cannot be used. The plug-in description of the standard version... Too simple
# Effect diagram

![Untitled.png]
Array arrangement + manual adjustment on the left, plug-in generation on the right (semi-finished product, not used yet)

> First order (iteration 1 time)

![image.png]
> Second order

![image.png]
> Fifth order

![image.png]
> Seventh order (plug-in limit 10 orders, my broken computer can run up to 7, and the page will crash if it is higher)

![image.png]
#
Download the compressed package of the plug-in installation project attachment - decompress it to get three files

![image.png]
1. Open **LiChuang EDA Standard Edition**, **LiChuang EDA Standard Edition**, **LiChuang EDA Standard Edition**Important things are said three times. Currently, the professional version does not support plug-ins. It needs to be generated by the standard version and then migrated to the professional version. The web version is currently tested, and the exe has not been tested yet.
2. Advanced--Extension--Extension Configuration

![image.png]
3. Click Load Extension - Select the three files extracted from the compressed file just now. Under normal circumstances, the extension ID will be automatically generated. If it is not generated, just enter an ID at random, and then click Load Extension to load successfully

![image.png]
4. The effect of successful loading (only the PCB interface has a button, and the schematic page has no button)

![image.png]

# Use the plug-in
1. Open a PCB file
2. Click the "Hilbert Curve" button in the menu
2. Enter the line width, line spacing, and number of iterations in the pop-up window, and then click Apply
3. The plug-in is executed, and a PCB file is automatically added. A Hilbert curve of the hc$9999 network is generated at the top level
**Note: ** See the figure below for the line width and line spacing. The number of iterations is actually the number of function recursions, that is, the order of the Hilbert curve, which is the total size of the graph in human terms

![image.png]
![image.png]
#
The way to import plug-ins in simple mode is tossing once, and you will save trouble in the future, but installing plug-ins is also a hassle. If you find it troublesome, change to a simpler way and run the script directly
1. Advanced--Extension--Run Script
2. Paste the code snippet in the main.js file, uncomment the three parameters, and modify them as needed
. 3. Click the run button to automatically generate the curve
. 4.
**Note:**

![image.png] ![image.png]
```
/********************************************Can run the script independently**************************************/
let width=1;//Line
widthlet spacing=2;//
Spacinglet iterations=4;//Number of iterations


//Unit conversionlet
pixelWidth = api('unitConvert', {
type: 'mm2pixel',
value: width
});
let pixelSpacing = api('unitConvert', {
type: 'mm2pixel',
value: spacing
})

let x = 0,
y = 0;
let h = pixelSpacing;
let maxGid = 1111;
var TRACK = {};
//Graphics iterationfunction
line(x1, y1, x2, y2) {
gid = "gge" + maxGid++;
TRACK[gid] = {
"gId": gid,
"layerid": "1",
"net": "hc$9999",
"pointArr": [{
"x": x1,
"y": y1
},
{
"x": x2,
"y": y2
}
],
"strokeWidth": pixelWidth
}
}

function One(n) // 方式(1)的递归调用
{
if (n > 0) {
Two(n - 1);

line(x, y, x, y += h);
One(n - 1);
line(x, y, x += h, y);
One(n - 1);
line(x, y, x, y -= h);
Four(n - 1);
}
}

function Two(n) // 方式(2)的递归调用
{
if (n > 0) {
One(n - 1);
line(x, y, x += h, y);
Two(n - 1);
line(x, y, x, y += h);
Two(n - 1);
line(x, y, x -= h, y);
Three(n - 1);
}
}

function Three(n) // 方式(3)的递归调用
{
if (n > 0) {
Four(n - 1);
line(x, y, x, y -= h);
Three(n - 1);
line(x, y, x -= h, y);
Three(n - 1);
line(x, y, x, y += h);
Two(n - 1);
}
}

function Four(n) // 方式(4)的递归调用
{
if (n > 0) {
Three(n - 1);
line(x, y, x -= h, y);
Four(n - 1);
line(x, y, x, y -= h);
Four(n - 1);
line(x, y, x += h, y);
One(n - 1);
}
}

var json = api('getSource', {
type: 'json'
});
One(iterations);

//线长
let length=spacing*Object.keys(TRACK).length;
console.log(`总线长:${length}mm`);

/*铜的电阻率: ρ=0.0175Ωmm2/m
走线长度: L
走线宽度: W
PCB铜厚度: D=0.035mm(加工消耗,采用0.03mm)
PCB走线电阻:R=(ρL)/(1000×WD)
R=(ρL)/(1000×WD)*/
let R=0.0175*length/1000/0.03/width;
console.log(`总阻值:${R}Ω`);
json = {

"DRCRULE": json.DRCRULE,
"preference": json.preference,
"SIGNALS": {},
"netColors": {},
"itemOrder": [],
"canvas": json.canvas,
"layers": json.layers,
"objectMap": json.objectMap,
"netRuleMap": {},
"head": json.head,
"BBox": json.BBox,
"importFlag": 0,
"PAD": {},
"TRACK": TRACK
}

api('applySource', {
source: json,
createNew: true
});


```

# Ending
For the direct reference of the Hilbert curve generation code, I would like to thank: [JavaScript Graphics Example: Hilbert Curve](https://www.cnblogs.com/cs-whut/p/13257224.html)
For plug-in development issues, I contacted the WeChat customer service of LiChuangeda, and the feedback was relatively timely. Thumbs up
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-22 15:36:33

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号