Dim sCompObj As ViewDraw.IVdComp
sCompObj = sCompColl.Item(sComp_Index)
If sCompObj.Label Is Nothing Then
sCompObj.AddLabel("test", 1, 2)
This fragment does not work - either in VBS Script nor withing VB.NET.
What is wrong?
I have found the problem - the component which should get the label - must be selected and visible in the ActiveView.
Otherwise you get the error note - "nothing selected".
AddLabel seems not to work on not visible components
component collection of all used components in design
visible is just the first page
AddLabel does not work on a component on page 2.
Visit page 2 - select the component and then do addlabel ...
Could anyone confirm my workaround?
I am using EE7.9.5 Update 21
Can you elaborate on "this fragment does not work"? Are you getting errors? Or are you not seeing the label added to the component?
Keep in mind the x,y arguments are absolute, not relative to the component.
Also, depending on your Display Settings, you may not be displaying names, so it is possible the label is being added but the name is not being displayed.
Most of the time this code framgment works as wanted. But sometimes - I get errors.
If it works I can see the label positioned and named as expected.
I know about the placement x,y arguments - this is just an example ;-) - in reality I get the position of the component first and the x/y arguments have some offsets to the component position.
Okay, you might want to use "On Error Resume Next" and check the Err.Number (if you are using VBScript) so you can identify the circumstances where the label is not correctly being added.
I'm curious why you would want to do this in the first place. Why not have whatever you want to attach to the component as a property from DxDatabook and then either show or hide that property? Adding labels at the design stage seems like the slow way around the mountain.
We need this to do - because some colleagues do not apply the checkbox - apply netnames to on/offsheets links ....
If this box is not checked - it happens, that the on/off sheet link has a wrong label - or the net does not have a name ....
So this scripts walks through the design and checks the netlabel versus on/off sheet linkname and gives error messages and warning messages to the output window of the running dxdesigner and corrects automaticly the on/offsheet link name to the netname ...
That's why I am doing this ...
Stop that problem before it starts with your corporate DxDesigner.xml file. In the Settings area, make sure this line is in place:
<key name="AUTOMATICALLY_PROPAGATE_NET_NAMES" value="1" readonly="1"/>
The 'readonly' part is the key. It makes it so that the setting is permanent and can't be changed by the user's .xml file or the user unchecking it Setup>Settings. Just make sure the corporate WDIR path is after the user WDIR path in the WDIR environment variable.
As for changing the label value with a script, I have had not much luck doing so. I tried a few different ways of doing it but none worked very well. So now, in the script I have to clean up and format the XREFs, I collect all the names that don't match the net names and report them out to a file, then alert the user that there are connectivity errors present, and suggest that they review the file. Not the most elegant solution, but it hasn't seemed to cause too many problems so far.
Stopping the problem before it occurs is the best solution. Eventually it's never a problem.
oh cool, I didn't know you could make those settings read only in the dxdesigner.xml
Just so you all know, there is a built in way to find these inconsistencies in your schematics already. Go to Tools -> Verify and check out drc-823 "Link and net naming consistency"
Retrieving data ...