阅读:2870回复:5
【分享】将自定义符号导入Style文件代码!
<P>内附详细的注释和说明:</P>
<P><a href="attachment/2005-11/200511416334967204.txt">2005-11/200511416334967204.txt</a><br></P> [此贴子已经被作者于2005-11-4 17:30:52编辑过]
|
|
1楼#
发布于:2005-11-14 11:39
呵呵,应该奖励的,少有的好人呐!
|
|
2楼#
发布于:2005-11-12 22:13
<P>好贴,好象有人发过关于怎样改造ao中的style文件,可以使ae调用,不知道大家有谁知道,可以共享一些解决方案和代码。</P>
|
|
3楼#
发布于:2005-11-07 13:33
<DIV class=quote><B>以下是引用<I>cftao2008</I>在2005-11-7 9:30:58的发言:</B><BR>耍一次小聪明也不让如愿!呵呵!就想试一试是什么样的效果!<img src="images/post/smile/dvbbs/em02.gif" /></DIV>
<P>哈哈,不错的东东 <P>赠送5个jb了</P><img src="images/post/smile/dvbbs/em02.gif" /> |
|
|
4楼#
发布于:2005-11-07 09:30
耍一次小聪明也不让如愿!呵呵!就想试一试是什么样的效果!<img src="images/post/smile/dvbbs/em02.gif" />
|
|
5楼#
发布于:2005-11-05 22:09
<P>的确是个好贴,支持一下!顺便帮你贴上:)</P>
<P>'这个过程完成了加载的全过成<BR>'日期:2005-09-15<BR><BR>Public Sub TruetypeToStyle()<BR><BR> Dim pStyleGallery As IStyleGallery 'Style文件的编辑环境<BR> Dim pStyleGalleryItem As IStyleGalleryItem '符号库中的一个符号队形<BR> 'Dim pMarkerSymbolStyleGalleryClass As IStyleGalleryClass<BR> Dim pItems As IEnumStyleGalleryItem '一组符号<BR> Dim pStylStor As IStyleGalleryStorage '管理编辑环境中的文件对象<BR> Dim pCharMarkerSym As ICharacterMarkerSymbol '将要添加到Style文件中的符号<BR> Dim pFont As IFont '字体<BR> Dim pFilePath As String '自定义Style文件的路径<BR> Dim pTargetFile As String '目标文件<BR> <BR> '将自定义Style文件添加到StyleGallery<BR> Set pStylStor = New StyleGallery<BR> Set pStyleGallery = pStylStor<BR> pFilePath = pStylStor.DefaultStylePath ; "CustomStyle.style"<BR> <BR> pTargetFile = pStylStor.TargetFile<BR> If pTargetFile = pFilePath Then<BR> '系统会默认一个路径<BR> Else<BR> pStylStor.TargetFile = pFilePath<BR> pStylStor.AddFile pFilePath<BR> End If<BR> '创建各个符号对象<BR> Set pFont = New SystemFont<BR> pFont.Name = "Cityblueprint"<BR> pFont.Italic = True<BR> Dim pCount As Long<BR> <BR> Dim pColor As IColor<BR> Set pColor = New RgbColor<BR> pColor.RGB = RGB(255, 0, 0)<BR> <BR> '要加载所有的字体中的符号需要你记下字体中的符号数目<BR><BR> Dim i As Long<BR> i = 0<BR> Set pCharMarkerSym = New CharacterMarkerSymbol<BR> With pCharMarkerSym<BR> .Angle = 0<BR> .Font = pFont<BR> .CharacterIndex = i<BR> .Color = pColor<BR> .size = 20<BR> .XOffset = 0<BR> .YOffset = 0<BR> End With<BR> <BR> <BR> Do While Not pCharMarkerSym Is Nothing<BR> <BR> Set pStyleGalleryItem = New StyleGalleryItem<BR> With pStyleGalleryItem<BR> .Category = "Default"<BR> .Name = "Try" + CStr(i)<BR> .Item = pCharMarkerSym<BR> End With<BR> <BR> '将创建的符号添加到指定的Style文件中去<BR> pStyleGallery.AddItem pStyleGalleryItem<BR> i = i + 1<BR> <BR> If i >= 400 Then<BR> Exit Do<BR> End If<BR> <BR> pCharMarkerSym.CharacterIndex = i<BR> Loop<BR> <BR> '删除添加的条目<BR> 'Set pItems = pStyleGallery.Items("Marker Symbols", pFilePath, "Default")<BR> 'pItems.Reset<BR> <BR> 'Dim pItem As IStyleGalleryItem<BR> 'Dim j As Long<BR> 'j = 0<BR> 'Set pItem = pItems.Next<BR> 'Do While Not pItem Is Nothing<BR> ' pStyleGallery.RemoveItem pItem<BR> 'Set pItem = pItems.Next<BR> ' j = j + 1<BR> ' Loop<BR> <BR> '清空内存<BR> 'pStylStor.RemoveFile pFilePath<BR> Set pStyleGallery = Nothing<BR> Set pStyleGalleryItem = Nothing<BR> Set pCharMarkerSym = Nothing<BR> Set pItems = Nothing<BR> Set pFont = Nothing<BR> Set pStylStor = Nothing<BR> Set pColor = Nothing<BR> 'Set pItem = Nothing<BR>End Sub<BR><BR>'功能:把Style文件从Style管理器中移出<BR>'日期:2005-09-15<BR><BR>Public Sub RemoveFileFromStyleManager()<BR> Dim pStyleGallery As IStyleGallery 'Style文件的编辑环境<BR> Dim pStylStor As IStyleGalleryStorage '管理编辑环境中的文件对象<BR> Dim pFilePath As String '自定义Style文件的路径<BR> <BR> '将自定义Style文件添加到StyleGallery<BR> Set pStylStor = New StyleGallery<BR> Set pStyleGallery = pStylStor<BR> pFilePath = pStylStor.DefaultStylePath ; "CustomStyle.style"<BR> pStylStor.RemoveFile pFilePath<BR> <BR> '清空内存<BR> Set pStyleGallery = Nothing<BR> Set pStyleGalleryItem = Nothing<BR> pFilePath = ""<BR> <BR>End Sub<BR><BR>'功能:删除指定Style文件中的符号<BR>'日期:2005-09-15<BR><BR>Public Sub RemoveItem()<BR> Dim pItems As IEnumStyleGalleryItem '一组符号<BR> Dim pStyleGallery As IStyleGallery 'Style文件的编辑环境<BR> Dim pFilePath As String<BR> Dim pStylStor As IStyleGalleryStorage '管理编辑环境中的文件对象<BR> <BR> pFilePath = "D:\Program Files\ArcGIS\Bin\Styles\CustomStyle.style"<BR> Set pStyleGallery = New StyleGallery<BR> Set pStylStor = pStyleGallery<BR> pStylStor.AddFile pFilePath<BR> <BR> Set pItems = pStyleGallery.Items("Marker Symbols", pFilePath, "Default")<BR> pItems.Reset<BR> <BR> If pItems Is Nothing Then<BR> Exit Sub<BR> End If<BR> <BR> '删除添加的条目<BR> Dim pItem As IStyleGalleryItem<BR> Dim j As Long<BR> j = 0<BR> Set pItem = pItems.Next<BR> Do While Not pItem Is Nothing<BR> pStyleGallery.RemoveItem pItem<BR> Set pItem = pItems.Next<BR> j = j + 1<BR> Loop<BR><BR>End Sub<BR><BR>注释:这个这些功能的总体思路是<BR>1、将Style文件添加到Style文件管理器<BR>2、创建一个符号<BR>3、将符号添加到Style文件<BR></P> |
|
|