XYX365 发表于 2015-9-2 10:17
接下来就要考虑“吕”字型的和“回”字形的封闭图形分别添加shape了,两位老师有什么好的建议么?
=>一 ...
现在“吕”已经完成了,但是“回”的,怎么将外面的shape避开里面的“口”?也就是两个shape没有重叠部分
leilei4908 发表于 2015-9-2 11:53
现在“吕”已经完成了,但是“回”的,怎么将外面的shape避开里面的“口”?也就是两个shape没有重叠部分
你怎麼處理"呂"的代碼?
可以貼上來嗎?
XYX365 发表于 2015-9-2 12:15
你怎麼處理"呂"的代碼?
可以貼上來嗎?
axlCmdRegister( "Polygon2Shape" `Polygon2Shape)
procedure( Polygon2Shape()
axlClearSelSet()
axlSetFindFilter(?enabled '("noall" "linesegs") ?onButtons '("noall" "linesegs"))
axlSingleSelectBox()
lines_listi = axlGetSelSet()
axlClearSelSet()
PathList = list(nil)
while(lines_listi
start = car(car(lines_listi)->startEnd)
end = cadr(car(lines_listi)->startEnd)
path = list(start end)
lines_listi = cdr(lines_listi)
closed = 1
while(last(path) != list(start) && closed
lMatch = setof(x lines_listi (car(x->startEnd) == end || cadr(x->startEnd) == end))
if(lMatch then
if(car(car(lMatch)->startEnd) == end then
path = append1(path cadr(car(lMatch)->startEnd))
end = cadr(car(lMatch)->startEnd)
else
path = append1(path car(car(lMatch)->startEnd))
end = car(car(lMatch)->startEnd)
)
lines_listi = remove(car(lMatch) lines_listi)
else
closed = nil
)
)
if(closed then
Path = axlPathStart(path)
PathList = append1(PathList Path)
)
)
foreach(closedPath PathList
axlDBCreateShape(closedPath t "Package Keepout/TOP")
)
axlVisibleLayer("Package Keepout/TOP" t)
axlVisibleUpdate(t)
axlSetFindFilter(?enabled '("all") ?onButtons '("noall"))
)
axlSetAlias("p2s" "Polygon2Shape")
针对这种line画的arc,我的path应该怎样处理?
leilei4908 发表于 2015-9-2 11:53
现在“吕”已经完成了,但是“回”的,怎么将外面的shape避开里面的“口”?也就是两个shape没有重叠部分
现在“吕”已经完成了,但是“回”的,怎么将外面的shape避开里面的“口”?也就是两个shape没有重叠部分
=> "回" 的處理方式可以使用axlPolyOperation()來處理
leilei4908 发表于 2015-9-2 12:51
针对这种line画的arc,我的path应该怎样处理?
Path = axlPathStart(path)
=>這一行只是取線段的開始和結束,所以只是在做Line,
如果要處理arc就必須在加入其他有關arc的參數.
你可以有關axlPath相關函數,
另外你寫的代碼裡面用到兩個while判斷,如果線段很多時,時間就拉長,
你可以在優化他,
或是你可以重新思考一下下面的流程
1.選擇要轉換的line
2.將所有line轉換為path (axlMakeDynamicsPath())
3.將path轉換為poly (axlPolyFromDB())
4.將poly轉換為shape (axlDBCreateShape())
XYX365 发表于 2015-9-2 13:26
Path = axlPathStart(path)
=>這一行只是取線段的開始和結束,所以只是在做Line,
如果要處理arc就必須在 ...
axlMakeDynamicsPath()
这个说明书中举的例子只有一个
Example
Simple r_path segment with a width of 20.
a = axlMakeDynamicsPath(list(list( 10:10 100:100 20)))
针对我这种应该怎么使用?
axlPolyFromDB())
这个说明书中的例子跟我的也不是很相关
Example 1
Create a poly from a via
polyList = axlPolyFromDB(via_dbid, ?layer "ETCH/BOTTOM" ?padType 'ANTI)
Example 2
Create a rectangle poly (one corner at 0,0 with a width 1000 and height of 500) using
r_path method
; note first and last points are the same
myPath = axlPathStart( list(0:0 1000:0 1000:500 0:500 0:0) 0)
pathPoly = axlPolyFromDB(myPath )
poly = car(pathPoly)
poly->??
能不能举几个相关的例子?
本帖最后由 XYX365 于 2015-9-3 07:22 编辑
leilei4908 发表于 2015-9-2 17:27
axlMakeDynamicsPath()
这个说明书中举的例子只有一个
Example
哈哈,寫程式很辛苦又很有趣吧
以下是我寫的代碼,供你參考axlSetFindFilter(?enabled list("noall" "linesegs") ?onButtons list("all"))
axlSelect() ;axlSingleSelectPoint()
lLines = axlGetSelSet()
axlClearSelSet()
lPath = nil
rPath = nil
tLayer = "PACKAGE GEOMETRY/ASSEMBLY_TOP"
lLastPoint = cadr(car(lLines)->startEnd) ;取第一個線段的結束位置
lStartXY = car(car(lLines)->startEnd)
lEndXY = cadr(car(lLines)->startEnd)
nWidth = car(lLines)->width
lCenterXY = car(lLines)->xy
nRadius = car(lLines)->radius
bClockwise = car(lLines)->isClockwise
rPath = cons(list(lStartXY lEndXY nWidth lCenterXY nRadius bClockwise) rPath)
lTempLines = cdr(lLines) ;取第二個以後的所有線段
xCount = 1
while(lTempLines && xCount <= length(cdr(lLines))
lMatchLines = setof(x lTempLines ((car(x->startEnd) == lLastPoint) || (cadr(x->startEnd) == lLastPoint)))
when(lMatchLines
if(car(car(lMatchLines)->startEnd) == lLastPoint then
lLastPoint = cadr(car(lMatchLines)->startEnd)
lStartXY = car(car(lMatchLines)->startEnd)
lEndXY = cadr(car(lMatchLines)->startEnd)
nWidth = car(lMatchLines)->width
lCenterXY = car(lMatchLines)->xy
nRadius = car(lMatchLines)->radius
bClockwise = car(lMatchLines)->isClockwise
rPath = cons(list(lStartXY lEndXY nWidth lCenterXY nRadius bClockwise) rPath)
else
lLastPoint = car(car(lMatchLines)->startEnd)
lStartXY = cadr(car(lMatchLines)->startEnd) ;要取第二個當作開始
lEndXY = car(car(lMatchLines)->startEnd) ;取第一個當作結束
nWidth = car(lMatchLines)->width
lCenterXY = car(lMatchLines)->xy
nRadius = car(lMatchLines)->radius
bClockwise = car(lMatchLines)->isClockwise
rPath = cons(list(lStartXY lEndXY nWidth lCenterXY nRadius bClockwise) rPath)
)
lTempLines = remq(car(lMatchLines) lTempLines) ;移除已處理的線段
)
;加入判斷第二個以上的lines所聯成的shape
when(cadr(car(rPath)) == car(car(last(rPath))) ;&& cadr(car(rPath)) == cadr(car(last(rPath)))) || (car(car(rPath)) == cadr(car(last(rPath))) && cadr(car(rPath)) == car(car(last(rPath))))
rPath = reverse(rPath)
lPath = cons(rPath lPath)
rPath = nil
;========================================
;再取第二個封閉的線段
lLastPoint = cadr(car(lTempLines)->startEnd) ;取第一個線段的結束位置
lStartXY = car(car(lTempLines)->startEnd)
lEndXY = cadr(car(lTempLines)->startEnd)
nWidth = car(lTempLines)->width
lCenterXY = car(lTempLines)->xy
nRadius = car(lTempLines)->radius
bClockwise = car(lTempLines)->isClockwise
rPath = cons(list(lStartXY lEndXY nWidth lCenterXY nRadius bClockwise) rPath)
lTempLines = cdr(lTempLines) ;取第二個以後的所有線段
)
xCount++
)
cond(
(onep(length(lPath))
rNewPath = axlMakeDynamicsPath(car(lPath))
lPoly1 = axlPolyFromDB(rNewPath ?endCapType 'ROUND)
axlDBCreateShape(car(lPoly1) t tLayer)
)
(length(lPath) == 2
rNewPath1= axlMakeDynamicsPath(car(lPath))
rNewPath2= axlMakeDynamicsPath(cadr(lPath))
lPoly1 = axlPolyFromDB(rNewPath1 ?endCapType 'ROUND)
lPoly2 = axlPolyFromDB(rNewPath2 ?endCapType 'ROUND)
dShapePoly1 = car(axlPolyOperation(lPoly1 lPoly2 'ANDNOT))
unless(dShapePoly1
dShapePoly1 = car(axlPolyOperation(lPoly2 lPoly1 'ANDNOT))
)
dShapePoly2 = car(axlPolyOperation(lPoly1 lPoly2 'AND))
cond(
(dShapePoly1 && dShapePoly2
axlDBCreateShape(dShapePoly1 t tLayer)
axlDBCreateShape(dShapePoly2 t tLayer)
)
(t
axlDBCreateShape(car(lPoly1) t tLayer)
axlDBCreateShape(car(lPoly2) t tLayer)
)
)
)
)
XYX365 发表于 2015-9-3 06:57
哈哈,寫程式很辛苦又很有趣吧
以下是我寫的代碼,供你參考
主要是对函数用法不了解,如果是我熟悉的C语言,那就轻松多了
XYX365 发表于 2015-9-3 06:57
哈哈,寫程式很辛苦又很有趣吧
以下是我寫的代碼,供你參考
dShapePoly1 = car(axlPolyOperation(lPoly1 lPoly2 'ANDNOT))
unless(dShapePoly1
dShapePoly1 = car(axlPolyOperation(lPoly2 lPoly1 'ANDNOT))
)
dShapePoly2 = car(axlPolyOperation(lPoly1 lPoly2 'AND))
cond(
(dShapePoly1 && dShapePoly2
axlDBCreateShape(dShapePoly1 t tLayer)
axlDBCreateShape(dShapePoly2 t tLayer)
)
(t
axlDBCreateShape(car(lPoly1) t tLayer)
axlDBCreateShape(car(lPoly2) t tLayer)
)
)
这里不是很理解,能解释下么