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的更多相关文章

  1. Multipart to single part feature

    Multipart to single part feature Explode Link: http://edndoc.esri.com/arcobjects/8.3/?URL=/arcobject ...

  2. [非官方]ArcGIS10.2 for Desktop扩展工具包——XTools Pro

    XTools Pro 是一套为ArcGIS平台设计的矢量空间分析. 形状转换和表管理扩展工具,大大增强了 ArcGIS 的功能,使用该工具能够提高 ArcGIS 用户的效率和性能. XTools Pr ...

  3. leaflet地图库

    an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...

  4. 关于arcgi s_api_for_flex的总结

    1.flex 的简介 a) Flex是adobe开发的东西,主要特点就是开发一个swf格式的应用,flex可以做桌面的应用和web的应用,但本质差不多. b) Flex采用mxml的格式来进行应用的布 ...

  5. POJ 3845 Fractal(计算几何の旋转缩放)

    Description Fractals are really cool mathematical objects. They have a lot of interesting properties ...

  6. POJ3041Asteroids(最小点覆盖+有点小抽象)

    Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18289   Accepted: 9968 Descri ...

  7. Milking Cows

    Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...

  8. POJ 3041 Asteroids

     最小点覆盖数==最大匹配数 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12678 Accepted:  ...

  9. Asteroids(匈牙利算法入门)

    Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16211   Accepted: 8819 Descri ...

随机推荐

  1. prim和kruskal比较

    推荐:http://squirrelrao.iteye.com/blog/1044867  http://www.cnblogs.com/xwdreamer/archive/2011/06/16/22 ...

  2. 利用javascript:void(0)制作假的提交按钮替代button

    在写html页面,我们很自然的在表单提交的地方采用button来作为提交按钮,但是,用<button type=”button”>按钮</button>作为提交代码会有个问题, ...

  3. tensorflow中 tf.train.slice_input_producer 和 tf.train.batch 函数

    tensorflow数据读取机制 tensorflow中为了充分利用GPU,减少GPU等待数据的空闲时间,使用了两个线程分别执行数据读入和数据计算. 具体来说就是使用一个线程源源不断的将硬盘中的图片数 ...

  4. JS字符串的问题

    首先,搞了好几个小时,头都大了,原来出在字符串问题上. 具体如下: 今天做Yii,遇到用JQuery 的AJAX方法做注册验证,把传回来的字符串与textField中的比较,发现相等,但是就是不出结果 ...

  5. Mac 终端下Homebrew的几个常用命令(新手笔记)

    最近在研究用appium来做IOS的自动化,所以开始接触Mac系统.记录一下在Mac的终端下Homebrew的几个常用命令 安装(需要 Ruby,不过一般自带都有):ruby -e "$(c ...

  6. 重新学习之spring第一个程序,配置IOC容器

    第一步:导入相关jar包(此范例导入的是spring3.2.4版本,spring2.5版本只需要导入spring核心包即可) 第二步:在项目的src下配置applicationContext.xml的 ...

  7. nexus bower 集成使用

    创建nexus bower proxy host 比较简单,如下图: 安装bower && bower-nexus resolver npm install -g bower-nexu ...

  8. Centos下telnet的安装和配置

    Centos下telnet的安装和配置 首先为Centos配置地址(192.168.0.1/24) 一.查看本机是否有安装telnetrpm -qa | grep telnetrpm -q telne ...

  9. application项目获取bean

    对于web项目,编程方式获取bean如下: WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); C ...

  10. ubuntu 16.04安装HUSTOJ过程

    一.背景介绍: 因为工作需要,想在学校搭建一个OJ平台用于程序测试与评价.于是需要搭建oJ,由于之前都是在云端服务器搭建系统,没有在实际服务器平台搭建过,所以遇到不少坑,都靠自己来填补.故而写下此教程 ...