#153356 - 05/12/13 11:52 PM
Visio Custom Properties
|
TexasBrownsFan
Fresh Scripter
Registered: 01/02/07
Posts: 36
Loc: Fort Worth , TX, USA
|
I am working on a script that will create a visio diagram. I can create the the document and add items to the document. The problem i am having is that i want to add custom properties to each of the items i place on the document. I basically created a macro of what i wanted to do and now i am trying to convert it from VB over to kixtart.
Here is the Code: Code:
Dim UndoScopeID1 As Long UndoScopeID1 = Application.BeginUndoScope("Define Custom Properties") Dim vsoShape1 As Visio.Shape Dim intPropRow2 As Integer Set vsoShape1 = Application.ActiveWindow.Page.Shapes.ItemFromID(2) intPropRow2 = vsoShape1.AddRow(visSectionProp, visRowLast, visTagDefault) vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsLabel).FormulaU = """Property1""" vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsType).FormulaU = "0" vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsFormat).FormulaU = """@""" vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsLangID).FormulaU = "1033" vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsCalendar).FormulaU = "" vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsPrompt).FormulaU = "" vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsValue).FormulaU = """Value1""" vsoShape1.CellsSRC(visSectionProp, intPropRow2, visCustPropsSortKey).FormulaU = "" Application.EndUndoScope UndoScopeID1, True
|
|
Top
|
|
|
|
#153357 - 05/12/14 10:32 AM
Re: Visio Custom Properties
|
Richard H.
Administrator
   
Registered: 00/01/24
Posts: 4939
Loc: Leatherhead, Surrey, UK
|
A quick direct conversion is: Code:
$TRUE=Not 0 $FALSE=Not $TRUE $UndoScopeID1 = $Application.BeginUndoScope("Define Custom Properties") $vsoShape1 = $Application.ActiveWindow.Page.Shapes.ItemFromID(2) $intPropRow2 = $vsoShape1.AddRow($visSectionProp, $visRowLast, $visTagDefault) $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsLabel).FormulaU = '"Property1"' $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsType).FormulaU = "0" $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsFormat).FormulaU = '"@@"' $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsLangID).FormulaU = "1033" $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsCalendar).FormulaU = "" $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsPrompt).FormulaU = "" $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsValue).FormulaU = '"Value1"' $vsoShape1.CellsSRC($visSectionProp, $intPropRow2, $visCustPropsSortKey).FormulaU = "" $Application.EndUndoScope($UndoScopeID1, $TRUE)
However, there are a number of variables or enumerations which you didn't include in your code sample, so I don't know if you have defined them elsewhere in your script.
|
|
Top
|
|
|
|
#153358 - 05/12/14 04:54 PM
Re: Visio Custom Properties
|
TexasBrownsFan
Fresh Scripter
Registered: 01/02/07
Posts: 36
Loc: Fort Worth , TX, USA
|
The script i am working on is a script that creates a visio diagram based on Active directory Site Information. The goal is to add custom attributes to each object that resides on the Visio document as the document is created.
I am still in the early developmental stages of the script. But here is the complete script along with the Area i am having issues with. Code:
; Script Name: VS-SiteOV.Kix ; Author: Bryan Sockel ; Script File Used to Pull Site Information from Active Directory and create a AD Site Overview Diagram
; **************************************************************************************************** ; Version Information ; ****************************************************************************************************
; Version 1.0 ; 12-12-2005 - Connects to Active Directory and Pulls Site Information From Active Directory and ; Creates a Visio Diagram
; **************************************************************************************************** ; Prerequisites ; **************************************************************************************************** ; In order for Script to work correctly, the PC that the script is run from must have the following: ; * Visio Professional, not Visio Standard Visio standard does not have the AD Stencils ; * Must Include the UDF for fnLDAPQuery() ; **************************************************************************************************** ; Main Script ; **************************************************************************************************** ;Cls Break on
include ".\Ldap.UDF" $PageCnt = 1 $StenRowCnt = 0
$AppVisio = CreateObject("visio.application") $docsObj = $AppVisio.Documents $DocObj = $docsObj.Add("ACTDIR_U.VST") $pagsObj = $AppVisio.ActiveDocument.Pages $pagObj = $pagsObj.Item(1)
; **************************************************************************************************** ; SiteOverView Diagram ; **************************************************************************************************** SSpacing() $ReportHeader = "Site Overview Diagram" ; Text To appear at the top of the Report $PageDesc = "SiteOV" ; Page Name $pagObj.Name = "$PageDesc-P$Pagecnt" $AppWindow = $AppVisio.ActiveWindow.Page $Header = $AppWindow.DrawRectangle(0.2, 10.5, 8.2, 10.8) ; Create Title Box $Header.TextStyle = "Normal" $Header.LineStyle = "Text Only" $Header.FillStyle = "Text Only" $Header.Text = "$ReportHeader" $aAttributes = "Name" $sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("ConfigurationNamingContext") $strFilter = "(&(objectClass=Site)(Name=*))" ; $strFilter = "(&(objectClass=Subnet)(Name=*))" ; Setting Filter for AD Query $SiteResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"Name") For $c = 0 to Ubound($SiteResults) For $r = 0 to UBound($SiteResults,2) $Site=$SiteResults[$c,$r] $A=AddStencil("ADO_U.vss","Site",$Site) Next Next
; **************************************************************************************************** ; Subnet OverView Diagram ; **************************************************************************************************** $=SSpacing() $ReportHeader = "Subnet Overview Diagram" ; Text To appear at the top of the Report $PageDesc = "SubnetOV" ; Page Name $=AddPage() $AppWindow = $AppVisio.ActiveWindow.Page $aAttributes = "CN" $strFilter = "(&(objectClass=Subnet)(Name=*))" ; Setting Filter for AD Query $SubnetResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"Name") For $c = 0 to Ubound($SubnetResults) For $r = 0 to UBound($SubnetResults,2) $Subnet=$SubnetResults[$c,$r] $=AddStencil("ADO_U.vss","IP Subnet",$Subnet) Next Next
Function AddStencil($VSS,$ObjType,$ObjText);,$StencilX,$StencilY) ; ****************************************************************************************** ; Function Creates Objects on Visio Document ; ****************************************************************************************** ; Creating Object On Visio Diagram $stnObj = $AppVisio.Documents("$VSS") $mastObj = $stnObj.Masters("$ObjType") $shpObj = $pagObj.Drop($mastObj, "$StencilX", "$StencilY") $shpObj.Text = "$ObjText" $shpObj.Name = "$ObjText" $shpObj.ID = "$ObjText"
; Icrementing Counters $StencilX = Cstr(Cdbl($StencilX) + CDbl($StenXSp)) ; Checking to see if they are at the end of the row ; If So Movin on to the next row. If $StencilX >= 8.25 $StencolCnt=0 $StencilY = CStr(cdbl($Stencily) - CDbl($StenYSP)) $StencilX = "0.5" Endif ; Checking to see if the page is full, if the page is full ; If the page is full Creating a new page in the work book and adding the header If $Stencily=0 ; Create a new Page $=AddPage() $StencilY="10.00" EndIf EndFunction
Function AddPage() ; ****************************************************************************************** ; Function Creates on New Visio Page And Adds Header ; ****************************************************************************************** $PageCnt = $PageCnt + 1 $pagsObj = $AppVisio.ActiveDocument.Pages $Addpage = $PagsObj.Add $addPage.Name = "$PageDesc-P$Pagecnt" $pagObj = $pagsObj.Item(2) $AppWindow = $AppVisio.ActiveWindow.Page $Header = $AppWindow.DrawRectangle(0.2, 10.5, 8.2, 10.8) $Header.TextStyle = "Normal" $Header.LineStyle = "Text Only" $Header.FillStyle = "Text Only" $Header.Text = "$ReportHeader" EndFunction
Function SSpacing() $StencilX = "0.5" ; Starting point for the Horizontal Rows $StencilY = "10.00" ; Starting Point for the veritcal rows $StenYSp = "0.5" ; Used to determing the Vertical Spacing of the Rows $StenXSp = "0.75" ; Used to determing the Horizontal Spacing of the Rows EndFunction
Edited by bsockel (05/12/15 07:45 PM)
|
|
Top
|
|
|
|
Moderator: Chris S., Shawn, ShaneEP, Sealeopard, Bryce, Jochen, Radimus, Kdyer, Howard Bullock, Glenn Barnas, Allen, Benny69, Mart
|
1 registered
(matzas)
and 62 anonymous users online.
|
|
|