Send Topic Feedback | See Object Hierarchy Chart
PC-DMIS 2023.2 Object Library
Add Method
Description
The Add function creates a new Label template in PC-DMIS.
Syntax
Visual Basic
Public Function Add() As LabelTemplate
Return Type
LabelTemplate object.
Example

Sub Label_Template_Creation()

    ' This test subroutine was created to show how label templates can be

    ' automatically generated using PC-DMIS Automation

    ' This was created inside Microsoft Excel

    

    ' Make sure PC-DMIS is running

    If MsgBox("This example will use your existing measurement routine and create an automatic Label Template. Is PC-DMIS running and is your measurement routine loaded?", vbYesNo, "Automated Label Template Creation") = vbNo Then

        MsgBox "Closing this example. Try again once PC-DMIS is running and a measurement routine is loaded.", vbExclamation

        Exit Sub

    End If

    

    ' Create the PC-DMIS Application

    Dim PCDApp As PCDLRN.Application

    Set PCDApp = CreateObject("Pcdlrn.Application")

    

    ' Open a Measurement Routine

    Dim PP As PartProgram

    Set PP = PCDApp.ActivePartProgram

    Dim LabelTemplates As LabelTemplates

    Set LabelTemplates = PCDApp.LabelTemplates

    Dim LabelTemplate As LabelTemplate

    

    ' Add a new Label Template

    Set LabelTemplate = LabelTemplates.Add

    

    ' Add a TextObject into a Label Template

    Set TextObj = LabelTemplate.LabelControls.Add(ID_HOB_TEXT, 0, 0, 50, 30)

    TextObj.Font = 16

    TextObj.Alignment = 1 ' To center it

    TextObj.BackColor = RGB(128, 0, 64)

    TextObj.ForeColor = RGB(255, 255, 255)

    TextObj.Text = "=ID" ' Code to display specified Feature ID or Dimension ID

               

    ' Save the changes to the Report Template

    LabelTemplate.SaveAs "d:\temp\TestLabelTemplate.lbl"

    MsgBox "The Label Template is now created. You can open it up inside of PC-DMIS to see what it looks like.", vbInformation, "Label Template Finished"

    LabelTemplate.Close

End Sub

See Also