Your Products have been synced, click here to refresh
Random questions (related to easier ways to learn the pcdmis type library). Do you have a acess to an offline seat of pc-dmis? If so, do you have access to vb6 or excel on that computer?
Begin VB.Form Form1 caption = "Visual Basic OLE Client for WinSPC" ClientHeight = 4485 ClientLeft = 60 ClientTop = 630 ClientWidth = 6150 LinkTopic = "Form1" ScaleHeight = 4485 ScaleWidth = 6150 Begin VB.TextBox Text1 Height = 4455 Left = 0 MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 0 Top = 0 Width = 6135 End Begin VB.Menu RunMenu Caption = "&Run" End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredID = True Attribute VB_Expose = False Sub Main 'PCDMIS commands Dim ObjApp As Object Dim ObjCmds As Object Dim ObjCmd As Object Dim ObjPart As Object Dim ObjDimCmd As Object Dim lngNumCmds As Long Set ObjApp = CreateObject("PCDLRN.Application") Set ObjPart = ObjApp.ActivePartProgram Set ObjCmds = ObjPart.Commands Dim StrDimID As String Dim StrDimFeature As String Dim StrDimType As String Dim StrDimNominal As String Dim StrDimUTol As String Dim StrDimLTol As String Dim StrDimMeasure As String Dim StrDimDiameter As String Dim DimName As String Dim DimMeas As String Dim MeasZ As String Dim StrC1 As Double Dim MyReading1 As Double Dim MyReading2 As Double Dim MyReading3 As Double Dim MyReading4 As Double Dim MyReading5 As Double Dim MyReading6 As Double For Each ObjCmd In ObjCmds If ObjCmd.IsComment Then If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then If ObjCmd.ID = "C1" Then StrC1 = ObjCmd.CommentCommand.Input End If End If End If If ObjCmd.IsDimension Then Set ObjDimCmd = ObjCmd.DimensionCommand StrDimID = ObjDimCmd.ID StrDimFeature = ObjDimCmd.Feat1 StrDimType = ObjDimCmd.AxisLetter StrDimNominal = ObjDimCmd.Nominal StrDimUTol = ObjDimCmd.Plus StrDimLTol = ObjDimCmd.Minus StrDimMeasure = ObjDimCmd.Measured ElseIf ObjCmd.IsFeature Then StrDimID = ObjCmd.FeatureCommand.ID StrDimDiameter = ObjCmd.FeatureCommand.MeasDiam MeasZ = ObjCmd.GetText(MEAS_Z,0) ElseIf (ObjCmd = FEATURE_CONTROL_FRAME) Then DimName = ObjCmd.ID DimMeasure = ObjCmd.GetFieldValue(LINE2_MEAS, 0) StrDimNominal = ObjCmd.GetFieldValue(LINE2_NOMINAL, 0) StrDimDev = ObjCmd.GetFieldValue(LINE2_DEV, 0) StrDimAct = StrDimNominal + StrDimDev End If If StrDimID = "CIR1- DIA UNDER GROOVE" Then MyReading1 = StrDimDiameter If DimName = "CIRC1 ROUNDNESS" Then MyReading2 = StrDimAct If StrDimID = "CIR2- DIA OF GROOVE" Then MyReading3 = StrDimDiameter If DimName = "CIR2- DIA OF GROOVE" Then MyReading4 = StrDimAct If StrDimID = "CIR3- DIA ABOVE GROOVE" Then MyReading5 = StrDimDiameter If DimName = "CIR3- DIA ABOVE GROOVE" Then MyReading6 = StrDimAct Next Dim dc As Object Dim CollectionPlanID As Object Dim Username As String Dim Password As String 'Open WinSPC and Collection Plan Set dc = CreateObject("WinSPC.DataCollectionAuto") dc.Visible = True dc.RunHeadless = False While dc.ReadyForLogin = "F" Wend dc.UserName = "1675 CMM" dc.Password = "1675" dc.CollectionPlanID = 8549 dc.TagIndex = 0 dc.TagValue = "P162610" dc.TagIndex = 1 dc.TagValue = StrC1 dc.CurrentStep = 0 dc.Value = MyReading1 dc.CurrentStep = 1 dc.Value = MyReading2 dc.CurrentStep = 2 dc.Value = MyReading3 dc.CurrentStep = 3 dc.Value = MyReading4 dc.CurrentStep = 4 dc.Value = MyReading5 dc.CurrentStep = 5 dc.Value = MyReading6 dc.CollectionPlanID = 0 dc.UserName = " " Set dc = Nothing End Sub
I just got pcdmis installed as an offline on my computer this morning and I do have excel, but not vb6.
Dim ObjApp as Application Dim ObjPart as PartProgram Dim ObjCmds as Commands Dim ObjCmd as Command Dim ObjDimCmd as DimensionCommand etc...
This is good. You can use VB in Excel to do all your development/debugging and more importantly, learn the pcdmis type library. You can set breakpoints, watches, step through your code line-by-line. While in debug mode, you can hover the mouse over a variable name and a tooltip will popup showing the contents. It's very powerful - I'd recommend picking up a book on VBA to help learn about the programming interface. Be sure to check out the Object Browser - you can set it to show only the pc-dmis objects and it's a great way to get a feel for the object hierarchy.
You'll need to set a reference to the pc-dmis type library in your project (Tools/References - scroll WAY down to the "p's" and check the pc-dmis library)
Add a module (Insert/Module) and paste your code into the module window (minus the form stuff)
Lastly, change Object declarations to the 'real' object type - like this:
Dim ObjApp as Application Dim ObjPart as PartProgram Dim ObjCmds as Commands Dim ObjCmd as Command Dim ObjDimCmd as DimensionCommand etc...
Once you're all finished debugging and are "production-ready" you'll have to change the declarations back to "Object" for use as pc-dmis script.
I really think that going this route will help you learn/understand the pc-dmis objects.
Thank you, I will definitely do it. Anything to make this easier. There are days that I just want to beat my head against the wall.
Add: Thank you so much, I have just started playing with it, and already I can see how useful this is. I wish I knew about this earlier. Fun, I now have new toys.
Yikes - don't do this! You have nested loops that scan through the entire program. So, if the program has 10,000 commands, you are going to scan through the entire program 10,000 times. Use one technique or the other, not both.
Dim App As Object Dim Part As Object Dim Cmds As Object Dim Cmd As Object Dim MyID As String Dim MyNom As String Dim MyDev As String Dim MyAx As String Dim Meas As String Sub Main() Set App = CreateObject("PCDLRN.Application") Set Part = App.ActivePartProgram Set Cmds = Part.Commands For Each Cmd In Cmds If Cmd.IsDimension Then MyID = Cmd.DimensionCommand.ID Meas = Cmd.DimensionCommand.Measured MyAx = Cmd.DimensionCommand.AxisLetter MsgBox MyID & Meas & MyAx End If Next End Sub
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |