Multipart polyline to single part lines
Breaking Up Polylines
http://forums.esri.com/Thread.asp?c=93&f=987&t=74554&mc=4#msgid197545
It appears as though IGeometryCollection is the way to go here, rather than ISegmentCollection. I noticed that the "ISegmentCollection" version created 905 line segments (from 15 polylines). ISegmentCollection created a line for every Single PAIR of vertices - 905 straight, two vertex lines.
There is no way I could have put this thing together at this point. Thanks for getting the ball rolling.
Hopefully, this can be useful to other users. Multipart lines can be a huge pain when you don't want them.
Sub ExplodePolyLines()
'
' From the original by Kirk Kuykendall.
'
Dim pUID As New UID
pUID.Value = "esricore.Editor"
Dim pEditor As IEditor
Set pEditor = Application.FindExtensionByCLSID(pUID)
If pEditor.EditState <> esriStateEditing Then
MsgBox "Make a shapefile editable."
Exit Sub
End If
Dim pEditlayers As IEditLayers
Set pEditlayers = pEditor
If pEditlayers.CurrentLayer.FeatureClass.ShapeType <> esriGeometryPolyline Then
Exit Sub
End If
Dim pFSel As IFeatureSelection
Set pFSel = pEditlayers.CurrentLayer
If pFSel.SelectionSet.Count = 0 Then
MsgBox "Select features to be broken up."
Exit Sub
End If
Dim pFCur As IFeatureCursor
pFSel.SelectionSet.Search Nothing, False, pFCur
pEditor.StartOperation
Dim pFeat As IFeature
Set pFeat = pFCur.NextFeature
Do Until pFeat Is Nothing
Dim pInGeomColl As IGeometryCollection
''' Dim pInSegColl As ISegmentCollection
''' Set pInSegColl = pFeat.ShapeCopy
Set pInGeomColl = pFeat.ShapeCopy
Application.StatusBar.Message(0) = "Exploding " & pFeat.OID
Dim l As Long
''' For l = 0 To pInSegColl.SegmentCount - 1
For l = 0 To pInGeomColl.GeometryCount - 1
''' Dim pOutSegColl As ISegmentCollection
''' Set pOutSegColl = New Polyline
Dim pOutGeomColl As IGeometryCollection
Set pOutGeomColl = New Polyline
''' pOutSegColl.AddSegment pInSegColl.Segment(l)
pOutGeomColl.AddGeometry pInGeomColl.Geometry(l)
Dim pOutFeat As IFeature
Set pOutFeat = pEditlayers.CurrentLayer.FeatureClass.CreateFeature
Dim k As Long
For k = 0 To pOutFeat.Fields.FieldCount - 1
If pOutFeat.Fields.Field(k).Editable Then
If pOutFeat.Fields.Field(k).Type <> esriFieldTypeGeometry Then
pOutFeat.Value(k) = pFeat.Value(k)
End If
End If
Next k
''' Set pOutFeat.Shape = pOutSegColl
Set pOutFeat.Shape = pOutGeomColl
pOutFeat.Store
Next l
pFeat.Delete
Set pFeat = pFCur.NextFeature
Loop
pEditor.StopOperation "Explode"
Dim pMxDoc As IMxDocument
Set pMxDoc = pEditor.Parent.Document
Dim pAV As IActiveView
Set pAV = pMxDoc.FocusMap
Dim lCacheID As Long
lCacheID = pAV.ScreenCacheID(esriViewGeoSelection, Nothing)
pAV.ScreenDisplay.Invalidate Nothing, True, lCacheID
MsgBox "Done"
End Sub
Multipart polyline to single part lines的更多相关文章
- Multipart to single part feature
Multipart to single part feature Explode Link: http://edndoc.esri.com/arcobjects/8.3/?URL=/arcobject ...
- [非官方]ArcGIS10.2 for Desktop扩展工具包——XTools Pro
XTools Pro 是一套为ArcGIS平台设计的矢量空间分析. 形状转换和表管理扩展工具,大大增强了 ArcGIS 的功能,使用该工具能够提高 ArcGIS 用户的效率和性能. XTools Pr ...
- leaflet地图库
an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...
- 关于arcgi s_api_for_flex的总结
1.flex 的简介 a) Flex是adobe开发的东西,主要特点就是开发一个swf格式的应用,flex可以做桌面的应用和web的应用,但本质差不多. b) Flex采用mxml的格式来进行应用的布 ...
- POJ 3845 Fractal(计算几何の旋转缩放)
Description Fractals are really cool mathematical objects. They have a lot of interesting properties ...
- POJ3041Asteroids(最小点覆盖+有点小抽象)
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18289 Accepted: 9968 Descri ...
- Milking Cows
Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...
- POJ 3041 Asteroids
最小点覆盖数==最大匹配数 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12678 Accepted: ...
- Asteroids(匈牙利算法入门)
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16211 Accepted: 8819 Descri ...
随机推荐
- AutoFac IoC DI 依赖注入
AutoFac IoC DI 依赖注入 记录点点滴滴知识,为了更好的服务后来者! 一.为什么使用AutoFac? 之前介绍了Unity和Ninject两个IOC容器,但是发现园子里用AutoFac的貌 ...
- iis6手工创建网站后无法运行php脚本
给人搬了十几个网站,老站用西部数码建站助手创建的,现在过期了无法继续创建,只能在Internet 信息服务(IIS)管理器创建网站,创建下来都没问题,但是就是无法打开网站. 测试打开txt文档.静态页 ...
- Java的变量相关
变量是在一个范围内的可变的值. 要点: 数据类型(确定变量的值的类型) 一个字节里面8个位,每个位里存储0101这样的二进制的补码表示用来数据,一个字节的数据类型的第一个位是符号位,表示正负. 数据类 ...
- Eclipse 项目有红惊叹号
Eclipse 项目有红感叹号原因:显示红色感叹号是因为jar包的路径不对 解决:在项目上右击Build Path -> Configure Build Paht...(或Propertise- ...
- MyEclipse web jsp 如何调试
MyEclipse如何调试 | 浏览:882 | 更新:2014-03-13 17:38 1 2 3 4 5 分步阅读 当程序写好之后,如何调试呢? 我们在MyEclipse中jav添加断点,运行de ...
- SqlServer高级特性--存储过程
需求: 用户需要提交加密数据,提交之后需要解密还原,还原有两种结果:成功和失败! 100个用户,之前7天,判断是否有提交数据,如果有提交有数据,判断是否解密成功(分别存在两个表中).如果没有提交,显示 ...
- SEO -- WP如何建立SiteMap
站点地图对网站的seo优化有着相当重要的作用,而WordPress的优势就是插件特别的多,也特别符合蜘蛛的口味,在wp上建立站点地图是相当简单的事情,只需要一款插件和几步简单的配置 Google XM ...
- bzoj 3144 [Hnoi2013]切糕——最小割
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3144 一根纵轴上切一个点,可以把一根纵轴上的点连成一串来体现.自己的写法是每个点连向前一个点 ...
- Spring AOP 实现读写分离
原文地址:Spring AOP 实现读写分离 博客地址:http://www.extlight.com 一.前言 上一篇<MySQL 实现主从复制> 文章中介绍了 MySQL 主从复制的搭 ...
- qt creator 快捷键 (二)
多使用快捷键能显著提高工作效率,尽可能减少键盘,鼠标之间切换所浪费的时间.我这里列出个人认为非常重要必须掌握的 Qt Creator 快捷键.看你知道几个? 1 .Ctrl(按住)+ Tab快速切换已 ...