leilei4908 发表于 2015-9-1 17:25:21

vivienluo 发表于 2015-9-1 16:55
判断一个path的起点或终点坐标与另一个path的起点或终点坐标是否一致。

procedure( Line2Shape()
        axlClearSelSet()
        axlSetFindFilter(?enabled '("noall" "linesegs")        ?onButtons '("noall" "linesegs"))
        axlSingleSelectBox()
        lines_listi = axlGetSelSet()
        lines_listj = cdr(lines_listi)
        axlClearSelSet()
        start = list(car(car(lines_listi)->startEnd))
        path = start
        foreach(i lines_listi
                foreach(j lines_listj
                        istart = list(car(i->startEnd)),iend = list(cadr(i->startEnd))
                        jstart = list(car(j->startEnd)),jend = list(cadr(j->startEnd))
                        if(istart == last(path) then
                                if(jstart == iend then path = append(iend path))
                                if(jend   == iend then path = append(iend path))
                        )
                        if(iend == last(path) then
                                if(jstart == istart then path = append(istart path))
                                if(jend   == istart then path = append(istart path))
                        )
                )
                lines_listj = cdr(lines_listj)
        )
        path = append(start path)
        axlSetFindFilter(?enabled '("all")        ?onButtons '("noall"))
        print(path)
)
axlSetAlias("l2s" "Line2Shape")
总是会漏掉好多点,罗老师帮我看看哪里有问题

XYX365 发表于 2015-9-1 21:18:21

leilei4908 发表于 2015-9-1 17:25
总是会漏掉好多点,罗老师帮我看看哪里有问题

你的代碼有問題,我修改為下列代碼
procedure(Line2Shape()
      axlClearSelSet()
      axlSetFindFilter(?enabled '("noall" "linesegs") ?onButtons '("noall" "linesegs"))
      axlSingleSelectBox()
      lines_listi = axlGetSelSet()
      lines_listj = cdr(lines_listi)
      axlClearSelSet()
      start = car(car(lines_listi)->startEnd)
      end = cadr(car(lines_listi)->startEnd)
      path = list(start end)
      while(lines_listj
              lMatch = setof(x lines_listj (car(x->startEnd) == end || cadr(x->startEnd) == end))
                    when(lMatch
                            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_listj = remove(car(lMatch) lines_listj)
                    )
            )
            axlSetFindFilter(?enabled '("all") ?onButtons '("noall"))
      print(path)
)

XYX365 发表于 2015-9-2 06:58:03

leilei4908 发表于 2015-9-1 09:07
不好意思,不能提供完整的源码,部分与问题不相关的已经删除

程式是正常的,
如果你要達成你的條件:
有没有什么方法在弹出确认框前就关闭V2VForm?

=>你可以在此行axlFormClose(V2VForm) 前面,加入 axlUIWShow(V2VForm 'hide) 就可以.

leilei4908 发表于 2015-9-2 09:08:52

本帖最后由 leilei4908 于 2015-9-2 09:23 编辑

XYX365 发表于 2015-9-1 21:18
你的代碼有問題,我修改為下列代碼

lMatch = setof(x lines_listj (car(x->startEnd) == end || cadr(x->startEnd) == end))
这一行代码我不理解是什么意图,是把listj中所有符合条件的x赋值给lMatch么
运行你的代码后程序就会无响应,应该是死循环了,是因为最后的
lines_listj = remove(car(lMatch) lines_listj)
没有把listj清空么?

XYX365 发表于 2015-9-2 09:19:52

本帖最后由 XYX365 于 2015-9-2 09:24 编辑

leilei4908 发表于 2015-9-2 09:08
lMatch = setof(x lines_listj (car(x->startEnd) == end || cadr(x->startEnd) == end))
这一行代码我 ...
lMatch = setof(x lines_listj (car(x->startEnd) == end || cadr(x->startEnd) == end))
这一行代码我不理解是什么意图,是把listj中所有符合条件的x赋值给lMatch么
=>是的

运行你的代码后程序就会无响应,应该是死循环了,是因为最后的
lines_listj = remove(car(lMatch) lines_listj)
没有把listj清空么?
=>問題可能是你的line沒有全連在一起或是你有框選兩個以上,由Line所組成的封閉線

解決方式改為下面
procedure(Line2Shape()
      axlClearSelSet()
      axlSetFindFilter(?enabled '("noall" "linesegs") ?onButtons '("noall" "linesegs"))
      axlSingleSelectBox()
      lines_listi = axlGetSelSet()
      lines_listj = cdr(lines_listi)
      axlClearSelSet()
      start = car(car(lines_listi)->startEnd)
      end = cadr(car(lines_listi)->startEnd)
      path = list(start end)
      xCount = 1
      while(lines_listj && xCount <= length(cdr(lines_listi))
                lMatch = setof(x lines_listj (car(x->startEnd) == end || cadr(x->startEnd) == end))
                  when(lMatch
                            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_listj = remove(car(lMatch) lines_listj)
                  )
                  xCount++
            )
            axlSetFindFilter(?enabled '("all") ?onButtons '("noall"))
      print(path)
)

leilei4908 发表于 2015-9-2 09:26:09

本帖最后由 leilei4908 于 2015-9-2 09:40 编辑

XYX365 发表于 2015-9-2 09:19
lMatch = setof(x lines_listj (car(x->startEnd) == end || cadr(x->startEnd) == end))
这一行代码我 ...

是这样的,我在框选的时候,肯定会选中封闭图形外的线,所以
lines_listj = remove(car(lMatch) lines_listj)
不会把listj清空
我应该增加一个判断,path回到起点就跳出循环
顺便问下
append和append1有什么区别

判断条件改成
while(last(path) != list(start)
就可以了
但是有个问题,如果listi中第一条线是封闭曲线外的线,那么也会进入死循环

XYX365 发表于 2015-9-2 09:37:44

leilei4908 发表于 2015-9-2 09:26
是这样的,我在框选的时候,肯定会选中封闭图形外的线,所以
lines_listj = remove(car(lMatch) lines ...

我应该增加一个判断,path回到起点就跳出循环)
=>這種方式也可以
顺便问下
append和append1有什么区别
=>append 是兩個list合併成一個list
append1是將後面的元素附加到list後面
cons是將元素附加到list最前面

XYX365 发表于 2015-9-2 10:02:24

leilei4908 发表于 2015-9-2 09:26
是这样的,我在框选的时候,肯定会选中封闭图形外的线,所以
lines_listj = remove(car(lMatch) lines ...


但是有个问题,如果listi中第一条线是封闭曲线外的线,那么也会进入死循环
=>你也可以加入判斷,只要判斷此條line的開始和結束位置是否一樣就知道

leilei4908 发表于 2015-9-2 10:08:17

XYX365 发表于 2015-9-2 10:02
但是有个问题,如果listi中第一条线是封闭曲线外的线,那么也会进入死循环
=>你也可以加入判斷,只要判 ...

接下来就要考虑“吕”字型的和“回”字形的封闭图形分别添加shape了,两位老师有什么好的建议么?

XYX365 发表于 2015-9-2 10:17:32

leilei4908 发表于 2015-9-2 10:08
接下来就要考虑“吕”字型的和“回”字形的封闭图形分别添加shape了,两位老师有什么好的建议么?

接下来就要考虑“吕”字型的和“回”字形的封闭图形分别添加shape了,两位老师有什么好的建议么?
=>一樣加入判斷,
只要第一個封閉的迴路完成後,
先將此path存放到list裡面,
再重新讀取剩下的,
並再將path附加到先前的list

只是這個判斷 while(last(path) != list(start) ,
可能要修改一下
页: 1 [2] 3 4 5
查看完整版本: 在调用Form后如何先关闭Form再执行后续程序?