Click on a text label and it will be converted to a net label, click on a text label on it will be converted to a net label.
Sub Label2Text
If SchServer Is Nothing Then Exit Sub
Set CurrentSheet = SchServer.GetCurrentSchDocument
If CurrentSheet is Nothing Then Exit Sub
Call SchServer.ProcessControl.PreProcess(CurrentSheet, "")
Set Alocation = CurrentSheet.Location
While CurrentSheet.ChooseLocationInteractively(Alocation,"Select Label")
Set HitTest = CurrentSheet.CreateHitTest(eHitTest_AllObjects, ALocation)
If (HitTest.HitTestCount > 0) Then
For I = 0 to (HitTest.HitTestCount-1)
If HitTest.HitObject(I).ObjectId = eLabel Then
Set SchLabel = SchServer.SchObjectFactory(eNetLabel,eCreate_GlobalCopy)
SchLabel.FontID = HitTest.HitObject(I).FontID
Schlabel.Text = HitTest.HitObject(I).Text
Schlabel.Location = HitTest.HitObject(I).Location
CurrentSheet.RegisterSchObjectInContainer(SchLabel)
CurrentSheet.GraphicallyInvalidate
CurrentSheet.RemoveSchObject(HitTest.HitObject(I))
Call SchServer.RobotManager.SendMessage(CurrentSheet.I_ObjectAddress,_
c_BroadCast,SCHM_PrimitiveRegistration,HitTest.HitObject(I).I_ObjectAddress)
ElseIf HitTest.HitObject(I).ObjectId = eNetLabel Then
Set SchLabel = SchServer.SchObjectFactory(eLabel,eCreate_GlobalCopy)
SchLabel.FontID = HitTest.HitObject(I).FontID
Schlabel.Text = HitTest.HitObject(I).Text
Schlabel.Location = HitTest.HitObject(I).Location
CurrentSheet.RegisterSchObjectInContainer(SchLabel)
CurrentSheet.RemoveSchObject(HitTest.HitObject(I))
CurrentSheet.GraphicallyInvalidate
Call SchServer.RobotManager.SendMessage(CurrentSheet.I_ObjectAddress,_
c_BroadCast,SCHM_PrimitiveRegistration,HitTest.HitObject(I).I_ObjectAddress)
End If
Next
End If
Wend
Call SchServer.ProcessControl.PostProcess(CurrentSheet, "")
CurrentSheet.GraphicallyInvalidate
End Sub
www.tdpcb.com
Altium Designer Script Information in VB for PCB Layout and Schematic Capture by Bill Smock from Tru Designs, San Diego, CA.
Showing posts with label Hit Test. Show all posts
Showing posts with label Hit Test. Show all posts
Thursday, July 14, 2011
Thursday, June 30, 2011
Hit Test Usage for Schematic
Using the ChooseLocationInteractively function to determine what is located at the cursor location when it is clicked. The HitTest stores all of the objects located at the cursor when clicked.
Sub HitTestExample
If SchServer Is Nothing Then Exit Sub
Set CurrentSheet = SchServer.GetCurrentSchDocument
If CurrentSheet is Nothing Then Exit Sub
Set Alocation = CurrentSheet.Location
Call CurrentSheet.ChooseLocationInteractively(Alocation,"Select Label")
Set HitTest = CurrentSheet.CreateHitTest(eHitTest_AllObjects, ALocation)
If (HitTest.HitTestCount > 0) Then
For I = 0 to (HitTest.HitTestCount-1)
ShowMessage ("ObjectID Is " & HitTest.HitObject(I).ObjectId)
Next
End If
End Sub
www.tdpcb.com
Sub HitTestExample
If SchServer Is Nothing Then Exit Sub
Set CurrentSheet = SchServer.GetCurrentSchDocument
If CurrentSheet is Nothing Then Exit Sub
Set Alocation = CurrentSheet.Location
Call CurrentSheet.ChooseLocationInteractively(Alocation,"Select Label")
Set HitTest = CurrentSheet.CreateHitTest(eHitTest_AllObjects, ALocation)
If (HitTest.HitTestCount > 0) Then
For I = 0 to (HitTest.HitTestCount-1)
ShowMessage ("ObjectID Is " & HitTest.HitObject(I).ObjectId)
Next
End If
End Sub
www.tdpcb.com
Labels:
ChooseLocation,
Hit Test,
Schematic
Subscribe to:
Posts (Atom)

