Your Products have been synced, click here to refresh
You can get vb.net express for free, but .net is a step change from vb scripts, although it might get you started with Object Orientated Programming.
Also there is VBA (Visual Basic for Applications) contained within MS Office - (Alt+F11) opens up the Development Environment.
(I still use this to browse the object model for PC-Dmis.)
Getting your head around Objects is kind of key, it's a gradual process but it's where you need to head.
I think PC-Dmis automation is actually quite a good learning resource as you can apply stuff to what you already know.
i.e.
Dim pcapp as Object
'(Dim is the key word used to declare a variable in VB, it's like ASSIGN in PC-Dmis
'In this case we're declaring pcapp as an Object Variable, unlike a normal variable which will typically store a bit of information, an object variable represents an object, from which we can access its properties, methods and functions
'More on this in a minute
Set pcapp = CreateObject("pcdlrn.application")
'This creates an object, in this case it creates an object representing the pcdmis application. You could also create an Excel "excel.application" or a Word "winword.application" objetct in order to control either of those bits of software
'You typically only use the CreateObject function to get hold of the top-level object like the application itself.
'Once we've got our claws into the main application we can do lots of stuff.
Dim pcpart as Object
'decalre another Object Variable
Set pcpart = pcapp.activepartprogram
'set its value to the active part program - we now have our claws into the active part program
'from here we can do more stuff
msgbox(pcpart.name)
'msgbox is like an operator comment. we're going to display the Name property of the active part program
'we could also access some of the part programs methods like close, quit, or save (pcpart.close, pcpart.quit, pcpart.save)
'More often than not we're going to want to do something with the commands within the program - guess how we do that?
'That's right, we create another object to represent the programs commands
Dim cmds as Object
Set cmds = pcpart.commands
'again we can access the commands properties (commands is a collection of individual commands)
msgbox(cmds.count)
'Count is the number of commands in the collection
'or we can step through the commands and do stuff
Dim cmd as Object
'This is going to represent each individual command in the program, one at a time
for each cmd in cmds
'for each is a looping technique, so for each command object, in the commands collection
msgbox(cmd.id)
'display the ID property
next
'move on the the next command
'There are lots of useful functions that allow us to target certain type of commands
for each cmd in cmds
if cmd.isdimension then
'Will only return TRUE if the command is a dimension command, the code within this IF statement will process only dimension type commands, it's no use me asking for the Measured property of an alignment - it doesn't exist
msgbox(cmd.dimensioncommand.meas)
'So we know this is a dimension command, we can then access the dimensioncommand properties and methods
'This will display the measured value for each dimension in the commands
end if
next
Right, that's all I've time for but it might give you an idea/get you started.
You can get vb.net express for free, but .net is a step change from vb scripts, although it might get you started with Object Orientated Programming.
Also there is VBA (Visual Basic for Applications) contained within MS Office - (Alt+F11) opens up the Development Environment.
(I still use this to browse the object model for PC-Dmis.)
Getting your head around Objects is kind of key, it's a gradual process but it's where you need to head.
I think PC-Dmis automation is actually quite a good learning resource as you can apply stuff to what you already know.
i.e.
Dim pcapp as Object
'(Dim is the key word used to declare a variable in VB, it's like ASSIGN in PC-Dmis
'In this case we're declaring pcapp as an Object Variable, unlike a normal variable which will typically store a bit of information, an object variable represents an object, from which we can access its properties, methods and functions
'More on this in a minute
Set pcapp = CreateObject("pcdlrn.application")
'This creates an object, in this case it creates an object representing the pcdmis application. You could also create an Excel "excel.application" or a Word "winword.application" objetct in order to control either of those bits of software
'You typically only use the CreateObject function to get hold of the top-level object like the application itself.
'Once we've got our claws into the main application we can do lots of stuff.
Dim pcpart as Object
'decalre another Object Variable
Set pcpart = pcapp.activepartprogram
'set its value to the active part program - we now have our claws into the active part program
'from here we can do more stuff
msgbox(pcpart.name)
'msgbox is like an operator comment. we're going to display the Name property of the active part program
'we could also access some of the part programs methods like close, quit, or save (pcpart.close, pcpart.quit, pcpart.save)
'More often than not we're going to want to do something with the commands within the program - guess how we do that?
'That's right, we create another object to represent the programs commands
Dim cmds as Object
Set cmds = pcpart.commands
'again we can access the commands properties (commands is a collection of individual commands)
msgbox(cmds.count)
'Count is the number of commands in the collection
'or we can step through the commands and do stuff
Dim cmd as Object
'This is going to represent each individual command in the program, one at a time
for each cmd in cmds
'for each is a looping technique, so for each command object, in the commands collection
msgbox(cmd.id)
'display the ID property
next
'move on the the next command
'There are lots of useful functions that allow us to target certain type of commands
for each cmd in cmds
if cmd.isdimension then
'Will only return TRUE if the command is a dimension command, the code within this IF statement will process only dimension type commands, it's no use me asking for the Measured property of an alignment - it doesn't exist
msgbox(cmd.dimensioncommand.meas)
'So we know this is a dimension command, we can then access the dimensioncommand properties and methods
'This will display the measured value for each dimension in the commands
end if
next
Right, that's all I've time for but it might give you an idea/get you started.
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |