Import custom symbols into the Style File Code

Source: Internet
Author: User

'This Process completes the loading process.
'Date:

Public sub truetypetostyle ()

Dim pstylegallery as istylegallery

'Style file editing Environment
Dim pstylegalleryitem as istylegalleryitem 'symbol

A symbolic formation in the database
'Dim pmarkersymbolstylegalleryclass

Istylegalleryclass
Dim pitems as ienumstylegalleryitem Group

Symbol
Dim pstylstor as istylegallerystorage Management

Edit file objects in the environment
Dim pcharmarkersym as icharactermarkersymbol' will

Symbol added to the Style File
Dim pfont as ifont font
Dim pfilepath as string 'custom

Path of the Style File
Dim ptargetfile as string 'Target

File

'Add the custom style file to stylegallery
Set pstylstor = new stylegallery
Set pstylegallery = pstylstor
Pfilepath = pstylstor. defaultstylepath &

"Customstyle. Style"

Ptargetfile = pstylstor. targetfile
If ptargetfile = pfilepath then
'The system will default a path
Else
Pstylstor. targetfile = pfilepath
Pstylstor. AddFile pfilepath
End if
'Create symbol objects
Set pfont = new systemfont
Pfont. Name = "cityblueprint"
Pfont. italic = true
Dim pcount as long

Dim pcolor as icolor
Set pcolor = new rgbcolor
Pcolor. RGB = RGB (255, 0, 0)

'To load all the characters in the font, you need to write down the number of characters in the font.

Dim I as long
I = 0
Set pcharmarkersym = new charactermarkersymbol
With pcharmarkersym
. Angle = 0
. Font = pfont
. Characterindex = I
. Color = pcolor
. Size = 20
. Xoffset = 0
. Yoffset = 0
End


Do while not pcharmarkersym is nothing

Set pstylegalleryitem = new stylegalleryitem
With pstylegalleryitem
. Category = "default"
. Name = "try" + CSTR (I)
. Item = pcharmarkersym
End

'Add the created symbol to the specified Style File
Pstylegallery. additem pstylegalleryitem
I = I + 1

If I> = 400 then
Exit do
End if

Pcharmarkersym. characterindex = I
Loop

'Delete the added entry
'Set pitems = pstylegallery. Items ("marker symbols ",

Pfilepath, "default ")
'Pitems. Reset

'Dim pitem as istylegalleryitem
'Dim J as long
'J = 0
'Set pitem = pitems. Next
'Do while not pitem is nothing
'Pstylegallery. removeitem pitem
'Set pitem = pitems. Next
'J = J + 1
'Loop

'Clear memory
'Pstylstor. removefile pfilepath
Set pstylegallery = nothing
Set pstylegalleryitem = nothing
Set pcharmarkersym = nothing
Set pitems = nothing
Set pfont = nothing
Set pstylstor = nothing
Set pcolor = nothing
'Set pitem = nothing
End sub

'Function: remove the style file from the style manager.
'Date:

Public sub removefilefromstylemanager ()
Dim pstylegallery as istylegallery

'Style file editing Environment
Dim pstylstor as istylegallerystorage Management

Edit file objects in the environment
Dim pfilepath as string 'custom

Path of the Style File

'Add the custom style file to stylegallery
Set pstylstor = new stylegallery
Set pstylegallery = pstylstor
Pfilepath = pstylstor. defaultstylepath &

"Customstyle. Style"
Pstylstor. removefile pfilepath

'Clear memory
Set pstylegallery = nothing
Set pstylegalleryitem = nothing
Pfilepath = ""

End sub

'Function: Delete the symbols in the specified Style File.
'Date:

Public sub removeitem ()
Dim pitems as ienumstylegalleryitem Group

Symbol
Dim pstylegallery as istylegallery

'Style file editing Environment
Dim pfilepath as string
Dim pstylstor as istylegallerystorage Management

Edit file objects in the environment

Pfilepath = "D:/Program

Files/ArcGIS/bin/styles/customstyle. Style"
Set pstylegallery = new stylegallery
Set pstylstor = pstylegallery
Pstylstor. AddFile pfilepath

Set pitems = pstylegallery. Items ("marker symbols ",

Pfilepath, "default ")
Pitems. Reset

If pitems is nothing then
Exit sub
End if

'Delete the added entry
Dim pitem as istylegalleryitem
Dim J as long
J = 0
Set pitem = pitems. Next
Do while not pitem is nothing
Pstylegallery. removeitem pitem
Set pitem = pitems. Next
J = J + 1
Loop

End sub

Note: the general idea of these functions is
1. Add the style file to the Style File Manager.
2. Create a symbol
3. Add the symbol to the style file.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.