ph363
Mechanical
- Jun 6, 2007
- 3
The below code finds all visible edges in a specified drawing view. From those edges, it determines start and end points and attepts to get the xyz coordinated of those points. It does not appear to be getting the correct coordinates b/c it fails on vertex reselection.
My goal is to collect coordinate data in an array which will be used to determine top, bottom, left, and right verticies on which dimensions will be placed (overall dimensions).
Any ideas why this is not pulling the correct coordinates?
'Get all visible components
vComps = swView.GetVisibleComponents
'Print name of first visible component
Debug.Print vComps(0).Name2
For comp = 0 To UBound(vComps)
' Get all edges on the first visible component
vEdges = swView.GetVisibleEntities(vComps(comp), swViewEntityType_Edge)
'Iterate through and select all edges on the first visible component
Set swSelData = swSelMgr.CreateSelectData
swSelData.View = swView
For itr = 0 To UBound(vEdges)
Set swEnt = vEdges(itr)
'boolstatus = swEnt.Select4(True, swSelData)
' Get and select the "Start" vertex
Set startVertexObj = swEnt.GetStartVertex
boolstatus = startVertexObj.Select4(True, swSelData)
' Get xyz corrdinates of selected "Start" vertex
startPt = startVertexObj.GetPoint
' Get and select the "End" vertex
Set endVertexObj = swEnt.GetEndVertex
boolstatus = endVertexObj.Select4(True, swSelData)
' Get xyz corrdinates of selected "End" vertex
endPt = endVertexObj.GetPoint
swModel.ClearSelection2 True
' Reselect "Start" and "End" verticies using coordinates
boolstatus = swModel.Extension.SelectByID2("", "VERTEX", startPt(0), startPt(1), startPt(2), False, 0, Nothing, 0)
boolstatus = swModel.Extension.SelectByID2("", "VERTEX", endPt(0), endPt(1), endPt(2), True, 0, Nothing, 0)
' Place dimension
Dim Annotation As Object
Set Annotation = swModel.AddDimension2(0.340726, 0.157093, -0.03995)
Next itr
Next comp
My goal is to collect coordinate data in an array which will be used to determine top, bottom, left, and right verticies on which dimensions will be placed (overall dimensions).
Any ideas why this is not pulling the correct coordinates?
'Get all visible components
vComps = swView.GetVisibleComponents
'Print name of first visible component
Debug.Print vComps(0).Name2
For comp = 0 To UBound(vComps)
' Get all edges on the first visible component
vEdges = swView.GetVisibleEntities(vComps(comp), swViewEntityType_Edge)
'Iterate through and select all edges on the first visible component
Set swSelData = swSelMgr.CreateSelectData
swSelData.View = swView
For itr = 0 To UBound(vEdges)
Set swEnt = vEdges(itr)
'boolstatus = swEnt.Select4(True, swSelData)
' Get and select the "Start" vertex
Set startVertexObj = swEnt.GetStartVertex
boolstatus = startVertexObj.Select4(True, swSelData)
' Get xyz corrdinates of selected "Start" vertex
startPt = startVertexObj.GetPoint
' Get and select the "End" vertex
Set endVertexObj = swEnt.GetEndVertex
boolstatus = endVertexObj.Select4(True, swSelData)
' Get xyz corrdinates of selected "End" vertex
endPt = endVertexObj.GetPoint
swModel.ClearSelection2 True
' Reselect "Start" and "End" verticies using coordinates
boolstatus = swModel.Extension.SelectByID2("", "VERTEX", startPt(0), startPt(1), startPt(2), False, 0, Nothing, 0)
boolstatus = swModel.Extension.SelectByID2("", "VERTEX", endPt(0), endPt(1), endPt(2), True, 0, Nothing, 0)
' Place dimension
Dim Annotation As Object
Set Annotation = swModel.AddDimension2(0.340726, 0.157093, -0.03995)
Next itr
Next comp