I was trying to read the BeginX, BeginY, EndX and EndY cells from all the connect object in a page, so that I could record which point from a shape is connected to which connect.
what confuses me is that the CellsU and CellsSRC seems to be not working with connect object, even it is suggested in office docs for like EndX cell. What shall I use if I want to read and save some cells from a connect object then?
You might find what you're looking for if you explore the objects returned from the connects() method on the connect object. Each object represents the connections made on each end of the connector and can lead you to the data in the shape object that has the coordinate information.
$c.Connects()
Application : Microsoft.Office.Interop.Visio.ApplicationClass
Stat : 0
FromSheet : System.__ComObject
ToSheet : System.__ComObject
FromCell : System.__ComObject
ToCell : System.__ComObject
FromPart : 9
ToPart : 3
ObjectType : 8
Index16 : 1
Document : System.__ComObject
Index : 1
ContainingPageID : 0
ContainingMasterID : -1
Application : Microsoft.Office.Interop.Visio.ApplicationClass
Stat : 0
FromSheet : System.__ComObject
ToSheet : System.__ComObject
FromCell : System.__ComObject
ToCell : System.__ComObject
FromPart : 12
ToPart : 3
ObjectType : 8
Index16 : 2
Document : System.__ComObject
Index : 2
ContainingPageID : 0
ContainingMasterID : -1
Related
I am trying to get the text of a ListView subitem in vb.net. according to this answer, the below code should work.
Function gen() As String
Dim Log = New Logging.Log("gen")
Dim Code As String = getTemplateCode()
For Each i As ListViewItem In ListView1.Items
Log.WriteEntry("Item: " + i.Text)
If i.SubItems.Count > 0 Then
Log.WriteEntry("Item: " + i.SubItems(0).Text)
Code = Code.Replace(i.Text, i.SubItems(0).Text)
End If
Next
Return Code
End Function
However, instead of getting string in ListViewItem.SubItem.Text, i am getting what seems to be the ListViewItem.Text, and cant figure out why.
Here's the actual log output from the above code:
gen Information: 0 : Item: $Parshah$
gen Information: 0 : Item: $Parshah$
gen Information: 0 : Item: $Year$
gen Information: 0 : Item: $Year$
gen Information: 0 : Item: $EnglishId$
gen Information: 0 : Item: $EnglishId$
gen Information: 0 : Item: $books$
gen Information: 0 : Item: $books$
gen Information: 0 : Item: $title$
gen Information: 0 : Item: $title$
and a screenshot of the listview
The log output should've been
gen Information: 0 : Item: $Parshah$
gen Information: 0 : Item: nothing
gen Information: 0 : Item: $Year$
gen Information: 0 : Item: nothing
gen Information: 0 : Item: $EnglishId$
gen Information: 0 : Item: nothing
gen Information: 0 : Item: $books$
gen Information: 0 : Item: nothing
gen Information: 0 : Item: $title$
gen Information: 0 : Item: nothing
What am I doing wrong?
Ok. Stupid mistake. A drop of research told me that a ListViewItem contains itself in its first subitem, and the first dynamically added subitem starts with an index of one instead of zero. (oops.)
Think Batch Arguments where %~0 is the file itself... lol.
SO, we change the code like this:
Function gen() As String
Dim Log = New Logging.Log("gen")
Dim Code As String = getTemplateCode()
For Each i As ListViewItem In ListView1.Items
Log.WriteEntry("Item: " + i.Text)
If i.SubItems.Count > 0 Then
Log.WriteEntry("Item: " + i.SubItems(1).Text) 'changed 0 to 1
Code = Code.Replace(i.Text, i.SubItems(1).Text) 'changed 0 to 1
End If
Next
Return Code
End Function
In CATIAV5 R26, I'm trying to dump the CATSettings related to the General --> Document tab to catvbs.
Consider that this should be a first step towards my final objective: fully automate settings with macros, as it is suggested in the official docs (http://www.maruf.ca/files/caadoc/CAAScdInfTechArticles/CAAInfSettings.htm)
I expect the dump function to create a catvbs containing ALL the settings of this tab, but instead, ONLY the DLName settings are written: the result is a General-Document.catvbs containing only the settings from CATSysDLNameSettingCtrl
The majority of settings, for example those inside the "Document Environment" or "Linked Documents Localization" sections (see image below) are not exported.
Is this inteded? Is this a bug? How can I be sure to have ALL settings exported to catvbs?
CATSettings Tab
Dumped General-Document.catvbs
Language="VBSCRIPT"
Sub CATMain()
Set settingControllers1 = CATIA.SettingControllers
Set dLNameSettingAtt1 = settingControllers1.Item("CATSysDLNameSettingCtrl")
Dim boolean1
boolean1 = dLNameSettingAtt1.DLNameCreationRight
'--------------------------------------------------
' Returned value : (Boolean) True
'--------------------------------------------------
Dim bSTR1
bSTR1 = ""
Dim bSTR2
bSTR2 = ""
Dim boolean2
boolean2 = dLNameSettingAtt1.GetDLNameCreationRightInfo(bSTR1, bSTR2)
'--------------------------------------------------
' Parameter 1 : (String) "Set at Admin Level 1"
' Parameter 2 : (String) "Locked at Admin Level 1"
' Returned value : (Boolean) False
'--------------------------------------------------
Dim boolean3
boolean3 = dLNameSettingAtt1.RootDLNameCreationRight
'--------------------------------------------------
' Returned value : (Boolean) True
'--------------------------------------------------
Dim bSTR3
bSTR3 = ""
Dim bSTR4
bSTR4 = ""
Dim boolean4
boolean4 = dLNameSettingAtt1.GetRootDLNameCreationRightInfo(bSTR3, bSTR4)
'--------------------------------------------------
' Parameter 1 : (String) "Default value"
' Parameter 2 : (String) "Unlocked"
' Returned value : (Boolean) False
'--------------------------------------------------
Dim arrayOfVariantOfBSTR1
arrayOfVariantOfBSTR1 = dLNameSettingAtt1.GetDLNameList()
'--------------------------------------------------
' Returned value : (Array)
' Array[0] : (Variant) (String) "My Sample DL Name"
'--------------------------------------------------
Dim bSTR5
bSTR5 = ""
Dim bSTR6
bSTR6 = ""
Dim bSTR7
bSTR7 = ""
dLNameSettingAtt1.GetDLName "My Sample DL Name", bSTR5, bSTR6, bSTR7
'--------------------------------------------------
' Parameter 1 : (String) "My Sample DL Name"
' Parameter 2 : (String) "/tmp/here"
' Parameter 3 : (String) "${MY_SAMPLE_VAR}"
' Parameter 4 : (String) ""
'--------------------------------------------------
Dim bSTR8
bSTR8 = ""
Dim bSTR9
bSTR9 = ""
Dim boolean5
boolean5 = dLNameSettingAtt1.GetDLNameInfo("My Sample DL Name", bSTR8, bSTR9)
'--------------------------------------------------
' Parameter 1 : (String) "My Sample DL Name"
' Parameter 2 : (String) "Set at Admin Level 1"
' Parameter 3 : (String) "Unlocked"
' Returned value : (Boolean) False
'--------------------------------------------------
End Sub
My mistake, I misunderstood your question. I would delete myself this answer but I it seems I cannot do it.
For your case it seems only DLNames is allowed and I suppose you will get only that catvbs.
If you want all catvbs for all catsettings then you need to do what is in picture bellow (see red arrow).
I'm afraid that not all the CATSettings are exposed to automation (as gdir correctly pointed out), including those I'm looking for.
as you can see in the documentation (emphasis mine)
In addition to using the Tools->Options... command, many settings can
be managed and administrated using Automation ...
many, not all.
This sadly prevents the full automation of CATSettings, as far as I know.
I have to create a really simple application in vb. My app contains a button and a listview. In my application i have to run threads, and insert in a listview the name and time of the thread executed. My code starts when i click on the threading button
my code is the following
Private Sub btnThreading_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThreading.Click
Try
For index = 0 To 3
Dim th As New Threading(index)
Me.Invoke(New DoStuffDelegate(AddressOf th.Run))
Next
lstText.View = View.Details
lstText.Columns.Add("Thread Name")
lstText.Columns.Add("Time")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
And the page threading is the following
Public Class Threading
Private threadName As String
Dim value As Date
Private Delegate Sub DoStuffDelegate()
Dim lockthis As New Object
Sub New(ByVal ThreadName As String)
Me.threadName = "Thread Number : " & ThreadName
End Sub
Public Sub Run()
For index = 0 To 3
Thread.Sleep(1000)
value = Date.Now
Console.WriteLine(threadName & " Time : " & value)
Dim item3 As New ListViewItem(Me.threadName)
item3.SubItems.Add(Me.value)
Form1.lstText.Items.AddRange(New ListViewItem() {item3})
Next
End Sub
End Class
if I use a thread without the delegate like the following
Dim th As New Threading(index)
Dim trd = New Thread(AddressOf th.Run)
trd.start()
, my output window shows the names and threads as it should for example
Thread Number : 1 Time : 9/15/2014 9:51:00
Thread Number : 0 Time : 9/15/2014 9:51:00
Thread Number : 2 Time : 9/15/2014 9:51:00
Thread Number : 3 Time : 9/15/2014 9:51:00
but doesn't show anything in the list view. but if i choose to use the delegate like the following,
Dim th As New Threading(index)
Me.Invoke(New DoStuffDelegate(AddressOf th.Run))
it shows the following in the output
Thread Number : 1 Time : 9/15/2014 9:50:59
Thread Number : 0 Time : 9/15/2014 9:51:00
Thread Number : 2 Time : 9/15/2014 9:51:01
Thread Number : 3 Time : 9/15/2014 9:51:02
and it shows it in the listview.So it works but doesn't execute the code as a thread does. But finally when I use the following code
Dim th As New Threading(index)
Dim trd = New Thread(AddressOf th.Run)
Me.Invoke(New DoStuffDelegate(AddressOf trd.Start))
, my output window shows the names and threads as it should for example
Thread Number : 1 Time : 9/15/2014 9:51:00
Thread Number : 0 Time : 9/15/2014 9:51:00
Thread Number : 2 Time : 9/15/2014 9:51:00
Thread Number : 3 Time : 9/15/2014 9:51:00
but doesn't show anything in the list view.
I want the list view to show this
Thread Number : 1 Time : 9/15/2014 9:51:00
Thread Number : 0 Time : 9/15/2014 9:51:00
Thread Number : 2 Time : 9/15/2014 9:51:00
Thread Number : 3 Time : 9/15/2014 9:51:00
All threads should have the same time, all threads should start at the same time,and they should appear in my list view.
Please help, I've been working on this for like two weeks and I'm not finding any solution!
What are you adding to the ListView? The name and the time, right? So, when you invoke a method on the UI thread, pas the name AND the time. Don't wait until you're on the UI thread to get the time because obviously that's going to be later.
I am trying to open a random access file using VB.NET I am getting the following error messge when attempting to access the file Error 75 (Access to the path ....is denied). Is there something that I must change to fix this?
Structure StdSections
'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
<VBFixedString(15), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=15)> Public A() As Char 'BEAM --- complete beam designation 15
'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
<VBFixedString(2), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=2)> Public B() As Char 'DSG --- shape ie "W" or "C" 2
Dim C As Single 'DN --- nominal depth of section 4
Dim d As Single 'WGT --- weight 4
.
.
.
End structure
''Note 'File1' holds complete path!
Public std As StdSections
Dim i,ffr,fLength,lastmembNo as integer
sectionFound = False
fLength = Len(std)
If fLength = 0 Then fLength = 168 ' 177
ffr = FreeFile()
'FileOpen(ffr, File1, OpenMode.Random, , , fLength)
FileOpen(ffr, File1, OpenMode.Random, OpenAccess.ReadWrite, OpenShare.LockRead, fLength)
>>Error 75 (Access to the path ....is denied) << path is perfectly good!!!
lastmembNo = CInt(LOF(ffr)) \ fLength
'ReDim std(lastmembNo)
For i = 1 To lastmembNo
FileGet(ffr, std, i)
If Trim(memberID) = Trim(std.A) Then
sectionFound = True
end if
next i
The first thing to check is permissions to the file in question. "Access to the path is denied" doesn't mean the path is bad or invalid, but that you either don't have permission, or the file is locked by another process. Still another possibility is a typo in the path variable (File1 in your sample)
I have an application I have been working on and it can be slow to start when my ISP is down because of DNS. My ISP was down for 3 hours yesterday, so I didn't think much about this piece of code I had added, until I found that it is always slow to start. This code is supposed to return your IP address and my reading of the link suggests that should be immediate, but it isn't, at least on my machine.
Oh, and yesterday before the internet went down, I upgraded (oymoron) to XP SP3, and have had other problems.
So my questions / request:
Am I doing this right?
If you run this on your machine does it take 39 seconds to return your IP address? It does on mine.
One other note, I did a packet capture and the first request did NOT go on the wire, but the second did, and was answered quickly. So the question is what happened in XP SP3 that I am missing, besides a brain.
One last note. If I resolve a FQDN all is well.
Public Class Form1
'http://msdn.microsoft.com/en-us/library/system.net.dns.gethostaddresses.aspx
'
'excerpt
'The GetHostAddresses method queries a DNS server
'for the IP addresses associated with a host name.
'
'If hostNameOrAddress is an IP address, this address
'is returned without querying the DNS server.
'
'When an empty string is passed as the host name,
'this method returns the IPv4 addresses of the local host
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim stpw As New Stopwatch
stpw.Reset()
stpw.Start()
'originally Dns.GetHostEntry, but slow also
Dim myIPs() As System.Net.IPAddress = System.Net.Dns.GetHostAddresses("")
stpw.Stop()
Debug.WriteLine("'" & stpw.Elapsed.TotalSeconds)
If myIPs.Length > 0 Then Debug.WriteLine("'" & myIPs(0).ToString)
'debug
'39.8990525
'192.168.1.2
stpw.Reset()
stpw.Start()
'originally Dns.GetHostEntry, but slow also
myIPs = System.Net.Dns.GetHostAddresses("www.vbforums.com")
stpw.Stop()
Debug.WriteLine("'" & stpw.Elapsed.TotalSeconds)
If myIPs.Length > 0 Then Debug.WriteLine("'" & myIPs(0).ToString)
'debug
'0.042212
'63.236.73.220
End Sub
End Class
See post #7 here Fix
A little power shell testing: Comments marked *
*returns in < 1 sec.
PS C:\Documents and Settings\MyPC> [System.Net.Dns]::GetHostAddresses("www.msn.com")
IPAddressToString : 65.55.17.27
Address : 454113089
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
IPAddressToString : 65.55.17.26
Address : 437335873
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
*takes about 40 seconds
PS C:\Documents and Settings\MyPC> [System.Net.Dns]::GetHostAddresses("")
IPAddressToString : 192.168.1.2
Address : 33663168
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
*returns in < 1 sec.
PS C:\Documents and Settings\MyPC> [System.Net.Dns]::GetHostAddresses("192.168.1.2")
IPAddressToString : 192.168.1.2
Address : 33663168
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
*takes about 40 seconds
PS C:\Documents and Settings\MyPC> [System.Net.Dns]::GetHostAddresses("")
IPAddressToString : 192.168.1.2
Address : 33663168
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
*i thought this should return several addresses
PS C:\Documents and Settings\MyPC> [System.Net.Dns]::GetHostAddresses("localhost")
IPAddressToString : 127.0.0.1
Address : 16777343
AddressFamily : InterNetwork
ScopeId :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
PS C:\Documents and Settings\MyPC>