About this task
A
|
Create an Add Blocks Button
|
B
|
Create a Mouse Up Event
|
C
|
Write a Script for the Add Blocks Button
|
D
|
Finish the Add Blocks Configuration
|
-
Create an Add Blocks Button
Procedure
-
Place a button on the CIMPTRACK screen.
-
Name the button Add Blocks.
Tip: Replace the default Button entry in the Text Button>String field.
-
(Optional) Select a different color for the button face.
-
Select the Events tab in the button's Properties dialog box.
-
Do the following.
A
|
Event field
|
Select Mouse Up in the drop down list.
|
B
|
Action
|
-
Click the Popup button to the right of the Action field.
-
Select New Script on the Popup menu.
|
Result: An Edit Script window opens.
-
Write a Script for the Add Blocks Button
The script includes the following sections
-
Declare a variable that's going to hold the item ID that the user enters.
Enter:
Dim itemid As String
Dim model As String
-
Create the input box that will prompt the user for an item ID and model type for the block.
Enter:
itemid = InputBox$("Enter BLOCK item ID, please","Item ID Entry","")
model = InputBox$("Enter BLOCK model type, please (valid entries: 25,36,60,99)","Model Type Entry","")
-
Take the value of the
itemid
string variable and create a new block item with the itemid
string variable as the new block item's ID.
Declare a new object of type prtitem
. Put this statement with your other variable declarations:
Enter:
Dim item As New prtItem
-
Add the code to add this new item to your schedule region.
Enter:
'Set the item properties
item.regionid="SCHEDULE"
item.itemid=itemid
item.itemtypeid=model
item.regionloc=-1
item.exthold 0
item.groupid="MAIN"
item.inthold 0
'Add the item to PRT
item.Add
-
Finish the Add Blocks Configuration
-
Compile the script.
-
Click File>Close on the Edit Script window menu bar to close the window.
-
Click OK to close the Properties dialog box.
Results
The CimEdit screen now has an Add Blocks button.