[求助]过滤图层出现的问题
我的程序是要选择dx-dgx图层的等高线,但是遇到下面的问题,要是 FilterData(1) = "DX-DGX" '直接写,是对的,但是FilterData(1) = lay,第一次运行这样是错的,lay是通过用户选取一条线的图层,以后运行就是对的,不知道为何?代码如下:acadobj.ActiveDocument.Utility.GetEntity returnobj1, basepnt1, "请选一条等高线,确定等高线所在的图层"
lay = returnobj1.Layer
mode = acSelectionSetFence
Dim FilterType(1) As Integer
Dim FilterData(1) As Variant
FilterType(0) = 0
FilterData(0) = "lwpolyline,spline"
FilterType(1) = 8
FilterData(1) = lay '"DX-DGX" '
paom.SelectByPolygon mode, ppoint, FilterType, FilterData
当我把cad全部关掉,再打开这张图,运行是错的,以后再运行就是好的,把图关掉,但是cad没有关,这样再打开这张图,运行也是好的,我想是不是有什么变量留在了cad那,这张图的坐标是ucs。
程序在VBA中调试没有问题啊,你看看
本帖最后由 mccad 于 2003-3-29 20:21:55 编辑Sub SelectByFence()
Dim returnobj1 As Object
Dim basepnt1 As Variant
Dim lay As String
Dim mode As Integer
Dim ppoint(0 To 5) As Double
Dim paom As AcadSelectionSet
Set paom = CreateSelectionSet
Utility.GetEntity returnobj1, basepnt1, "请选一条等高线,确定等高线所在的图层"
lay = returnobj1.Layer
mode = acSelectionSetFence
Dim FilterType(1) As Integer
Dim FilterData(1) As Variant
FilterType(0) = 0
FilterData(0) = "lwpolyline,spline"
FilterType(1) = 8
FilterData(1) = lay '"DX-DGX" '
Debug.Print lay
ppoint(0) = 1
ppoint(1) = 1
ppoint(2) = 0
ppoint(3) = 10
ppoint(4) = 10
ppoint(5) = 0
paom.SelectByPolygon mode, ppoint, FilterType, FilterData
End Sub
Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet
Dim ss As AcadSelectionSet
On Error Resume Next
Set ss = ThisDrawing.SelectionSets(ssName)
If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
ss.Clear
Set CreateSelectionSet = ss
End Function
好像不行
本帖最后由 作者 于 2003-3-29 17:43:13 编辑这样会返回空值lay=“”什么也没有的,
还有我这个图是用的是ucs坐标,不是world ,不知道和这样有没有关系
我是把vb获得直线的两个断点的world坐标转化为ucs坐标,因为我的fence方式是通过选择直线来实现的 。再
paom.SelectByPolygon mode, ppoint, FilterType, FilterData
ppoint的坐标是直线的ucs坐标
[求助]对于我自己画的图是可以?但是那张图就不行了
[求助]对于我自己画的图是可以?但是那张图就不行了,我试过除非 在filterdata(1)那里直接写图层的名字“DX-DGX”如果用选取直线再返回的时候,第一次是错的(能够返回图层的名字,但是选择直线相交的实体并没有全部选中),但是以后运行就是对的。这个图是用的ucs,我先获取直线的起点和终点的坐标(wcs),再转换ucs的坐标,放到filterlist里面,我想是不是我这一步有问题?
页:
[1]