xtoolbox / pcad2kicad Goto Github PK
View Code? Open in Web Editor NEWConvert Altium Designer and PCAD library to KiCad
License: MIT License
Convert Altium Designer and PCAD library to KiCad
License: MIT License
.lia封装库中含有 或者/ 等特殊字符的封装名字,无法转换,直接报错
Unknown record type 10 in D:\KiCAD_data\my_libraries\ad_schlib/IR120/7V16000001
CORNER.X=20
LINEWIDTH=1
OWNERPARTID=1
COLOR=136
CORNERXRADIUS=2
ISSOLID=T
AREACOLOR=11599871
LOCATION.Y=-20
CORNERYRADIUS=2
RECORD=10
LOCATION.X=-20
CORNER.Y=20
INDEXINSHEET=8
ISNOTACCESIBLE=T
Unknown record type 10 in D:\KiCAD_data\my_libraries\ad_schlib/IR120/CS0806S
CORNER.X=40
LINEWIDTH=1
OWNERPARTID=1
COLOR=136
CORNERXRADIUS=2
ISSOLID=T
AREACOLOR=11010047
LOCATION.Y=-30
CORNERYRADIUS=2
RECORD=10
LOCATION.X=-40
CORNER.Y=30
INDEXINSHEET=7
ISNOTACCESIBLE=T
Unknown record type 10 in D:\KiCAD_data\my_libraries\ad_schlib/IR120/7M20000011
CORNER.X=20
LINEWIDTH=1
OWNERPARTID=1
COLOR=136
CORNERXRADIUS=2
ISSOLID=T
AREACOLOR=11599871
LOCATION.Y=-20
CORNERYRADIUS=2
RECORD=10
LOCATION.X=-20
CORNER.Y=20
INDEXINSHEET=8
ISNOTACCESIBLE=T
Convert D:\KiCAD_data\my_libraries\ad_schlib/IR120.SchLib to D:\KiCAD_data\my_libraries/5k_IR120.lib done
转换的过程中有这些错误提示,转换完之后添加到工程,报错:
无法从库"5k_IR120"加载别名
I have a set of libraries from Altium CERN Library, I faced with varieties problems while I'm using this tool by you. I tried to change the code and test, but ending with failure.
Here is some of the library components those can represent the problems.
https://github.com/CarlNobody/Temporary/blob/main/Schlib1.SchLib
Problems list:
a. Alternative part will exist with the normal part in the converted library.
b. Curved object has wrong radius or wrong direction.
c. Designators those have space will lead an error.
d. Sometimes the conversion will failed with the error nil from not existing directory of the altium schematic part.
I‘m not a LUA developer, but I tried to solve them. What I tried for the corresponding problems are:
a. No solutions.
b. Not very good try, but converted library can be used.
local function parseArc(block, fonts, comp)
local x = ad2kicad_CoordValue(block['LOCATION.X'])
local y = ad2kicad_CoordValue(block['LOCATION.Y'])
local r = ad2kicad_CoordValue(block.RADIUS)
local startAngle = block.STARTANGLE or 0
local sweepAngle = block.ENDANGLE or 0
sweepAngle = sweepAngle - startAngle
print("startAngle=",startAngle," sweepAngle=",sweepAngle, " r=",r)
local width = getWidth(block.LINEWIDTH)
-- Start of additions.
if (r <60 ) and ( r>25) and ((tonumber(startAngle) == 270) or (tonumber(startAngle) == 90))then
r = r - 25
startAngle = -180+startAngle
else if( r <= 25) then
startAngle = -180+startAngle
end
end
-- Ending of additions.
local v = toKicadArc(x,y,r,startAngle, sweepAngle, width,"symbol")
v.part = block.OWNERPARTID or 0
local f = block.ISSOLID and block.ISSOLID == 'T'
v.fill = f and 'f' or 'N'
v.bbox = BBOX.create(r*2,r*2)
v.bbox = BBOX.moveTo(v.bbox, x, y)
comp.graphs[#comp.graphs+1] = v
end
c. Solved the problem.
local function parseText(block,fonts,comp)
local t = block.NAME or 'user'
local value = get_str(block, "TEXT")
local x = ad2kicad_CoordValue(block['LOCATION.X'])
local y = ad2kicad_CoordValue(block['LOCATION.Y'])
local rotate = block['ORIENTATION'] or 0
local hide = false
local just = tonumber(block.JUSTIFICATION) or 0
if block.ISHIDDEN and block.ISHIDDEN=='T' then
hide = true
end
rotate = tonumber(rotate) * 90
local font = buildFont(block.FONTID, fonts)
local hJust = ad2kicad_textJustify[just] and ad2kicad_textJustify[just][2] or 'C'
local vJust = ad2kicad_textJustify[just] and ad2kicad_textJustify[just][1] or 'C'
if t == 'Designator' then
value = string.sub(value,1,-2)
-- Start of additions.
value=string.gsub(value," ", "_")
-- Ending of additions.
comp.ref = value == "" and 'U' or value
end
d.To ensure conversion successfully, nil related components can be skipped.
if blocks == nil then
r.toSymbol = nil
return
end
$ lua53.exe ad2kicad.lua Core52840.PcbLib
No comp in file Core52840/FileHeader
lua53.exe: .\ad_lib.lua:924: attempt to get length of a nil value (local 'compList')
stack traceback:
.\ad_lib.lua:924: in function 'parse_schlib'
.\ad_lib.lua:945: in function 'convert_schlib'
ad2kicad.lua:95: in main chunk
[C]: in ?
从ad中操作导出开始,一个流程走下来就好了.
Did I missing some important file?
I get:
$ lua53.exe ad2kicad.lua ../ag35.schlib ag35
Der Befehl "7z" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
../ag35/FileHeader: No such file or directory
C:\mybin\lua53.exe: .\ad_lib.lua:143: attempt to get length of a nil value (local 'blocks')
stack traceback:
.\ad_lib.lua:143: in upvalue 'parse_Header'
.\ad_lib.lua:922: in function 'parse_schlib'
.\ad_lib.lua:945: in function 'convert_schlib'
ad2kicad.lua:95: in main chunk
[C]: in ?
PS. 7z is installed and found, so I have no idea what that complaint is about!
Hi!
Do you have any working examples and instructions how to use this?
We're trying to import some AD .pcbLib
and .SCHLIB
files into KiCad...
(padStyleDef "EF256X138TOP1"
(holeDiam 0mil)
(startRange 1)
(endRange 2)
(padShape (layerNumRef 1) (padShapeType Polygon) (shapeOutline
(pt 93.504mil 68.898mil)
(pt 127.953mil 34.449mil)
(pt 127.953mil -34.449mil)
(pt 93.504mil -68.898mil)
(pt -93.504mil -68.898mil)
(pt -127.953mil -34.449mil)
(pt -127.953mil 34.449mil)
(pt -93.504mil 68.898mil)
)
)
(padShape (layerNumRef 2) (padShapeType Ellipse) (shapeWidth 0.0) (shapeHeight 0.0) )
(padShape (layerType Signal) (padShapeType Ellipse) (shapeWidth 0.0) (shapeHeight 0.0) )
(padShape (layerType Plane) (padShapeType NoConnect) (shapeWidth 0.0) (shapeHeight 0.0) )
(padShape (layerType NonSignal) (padShapeType Oval) (shapeWidth 0mil) (shapeHeight 0mil) )
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.