Johns (tool) Bar

Hi Thomas and welcome to the bar.

Got errors loading your form.

:nauseated_face:

Line 8: Property OleObjectBlob in frmRev had an invalid file reference.
Line 2: Cannot load control frmRev.

But if you’d tell me what trick you used I could take it from there?

:+1:

Hello John -

Forgot to include that all important .frx file that comes with the .frm file - I updated the zip file with it in the original reply.

Basically - the form contains two controls, a list box of paths in the active station, and a command button that performs the following:

Private Sub cbReversePath_Click()

Dim i As Integer
Dim p1 As Path
Dim p2 As Path
Dim tr As TargetRef
Dim strName As String

'remove any path named “Reversed”
On Error Resume Next
ActiveStation.Paths(“Reversed”).Delete
On Error GoTo 0

If Me.cmbPath.Text <> “” Then
Set p1 = ActiveStation.Paths(Me.cmbPath.Text)
Set p2 = ActiveStation.Paths.Add()
p2.Name = “Reversed”

For i = p1.TargetRefs.Count To 1 Step -1
Set tr = p2.Insert(p1.TargetRefs.Item(i).Target)
tr.MotionType = p1.TargetRefs.Item(i).MotionType
Next i

'remove any path named “DeleteMe”
strName = p1.Name
On Error Resume Next
ActiveStation.Paths(“DeleteMe”).Delete
On Error GoTo 0

'renname the paths
p1.Name = “DeleteMe”
p2.Name = strName

'remove the source path
ActiveStation.Paths(“DeleteMe”).Delete
End If

End Sub

Private Sub UserForm_Initialize()

Dim sPath As Path

For Each sPath In ActiveStation.Paths
Me.cmbPath.AddItem sPath.Name
Next
End Sub

I haven’t tested this, but I think that you loose the motion properties in this example. There is an old topic “VBA Example: Config Path” which includes a routine that copies a path including all motion properties. This is what you have to do also when reversing the path.

Here is Johnsbar v1.3

Just the addin (for RS version 3.0+ English):
Johnsbar_dll.zip

With sourcecode as well (must have VB and RS v 2.0+ English):
Johnsbar_source.zip

To add an add-in to RS:

  1. Extract the folder to ABB RoboticsAddins
  2. Open RS
  3. Tools>Add-ins
  4. Add, browse to the dll (you need to have dll visible in MS Windows)
  5. OK
    =:star::star::star::star::star:

Right now these are the buttons:

Floor
Visible on/off

MultiRename
First, select any number of objects you wish to rename (like a whole list of targets), then click the MultiRename button. It will rename them in the order selected so you can ctrl+click in any order you wish.
There are three fields:
Name: Fill in the Name that all targets should get
Start: Fill in the number of the first object
Step: Fill in the number to add to each consecutive object
(example: If you select four targets and fill in “p”,“10”, “10”, they would be renamed to p10, p20, p30 and p40)
Do not click while running a simulation.

SaveAsLibrary
First select a Part, Assembly or Mechanism. This opens up the SaveAsLibrary dialog. (If this one is popular I intend to add a second File toolbar with Import:Library, Import:Geometry, etc)
Do not click while running a simulation.

Update rate
Here you can increase or decrease the Update rate, ie the simulation speed. It also works during Simulation so that you can “Fastforward”.
(The idea for this one was stolen from Henrik)

TCP View Center
Click to change the view to the TCP. (You can click this during simulation to jump to the TCP). The TCP is the one that you currently have selected in the Elements toolbar. So as long as it is in the list you can change to any tool in the station.

MultiVisible :star:New:star:
Select any number of objects and click to toggle Visible On/Off.
Right now there is no check for illegal objects, I will add that later. :stuck_out_tongue_winking_eye:

PartVisible :star:New:star:
Select a part in the browser and click the button. A form will open up that lists all enteties in the part and if they are visible or not. There are three buttons in the form:
Make All Visible, that makes all enteties visible.
Make None Visible, that makes all enteties not visible.
Reverse Visible, that reverses the visible setting for all the enteties.
The form is not that beautiful but it works.

PartReverse :star:New:star:
Select a path in the browser and click the button. It will now create a reverse of that path. Including reversing circular motion and retaining all motion data. (Thanks to Per S, Martin L and Thomas J who all supplied code… Pers didn’t copy process data, Thomas didn’t copy circular and Martin’s didn’t copy but got the data. But the mix of them all helped me get it right.)
Don’t click during simulation.

I’m sorry it took me so long to check out the new multi/partVisible option, but i finally got some free time to spend trying it. And.. it works :D.. Most of my former problems with retrieving invisible entities are history. I hope to be able to look further into this option this week. I’ll let you know…

Oh, and i almost forgot.. John if you ever experiance the feeling of “what the hell should i do now”, I might have another time-spender for you. But it’s going to be difficult..

I frequently need to take a close look at the movements of the tool. And to be able to take a good look at the tool while it travels along a path, i have to reposition the viewing-angle multiple times during the execution of the program.

Now here comes the nifty part.. What about a function that lets you follow the TCP. With this i mean that the graphics area of RobotStudio follows the TCP-movements at a certain distance and/or angle..

And although i suspect that this isn’t possible with VBA, I’d really like to hear your thoughts about this.

->Melk

Difficult? No, no, no. That’s easy.

If you look at the toolbar right now you’ll see the TCP View Center button. You can click it during simulation and ‘follow’ the TCP around.

But if you want it to be done automatically then just create a simulation controller (like the ‘How to move it’ example) and in the simulation.tick event just set the view center to be the tcp. If you want you could have a user option form that adds distance and angle if you wish.

I’ve certainly noticed the TCP View Center button, but if it could be automated, and with an option form that allows you to change distance and angle.. Well.. that would be super! Too bad i’m a total loss when it comes VBA..

:imp:

Go to the http://forums.robotstudio.com/forum_posts.asp?TID=82&PN=1 “How to move it” post and download the instruction.

But instead of moving a box you want to move along with the TCP.
So replace the controller code with this:

'This code should be pasted into the controller
'to create one right click theRobotStudioProject select Insert>Controller Class
'In this example the controller is named Movement so you need to name yours that as well
Dim tmpVector As RsMathVector
Dim tmpMatrix As RsMathMatrix
Private Sub Controller_AfterTick(ByVal Time As Double)
ActiveView.LookAt.x = ActiveStation.ActiveMechanism.ActiveToolFrame.Transform.x
ActiveView.LookAt.y = ActiveStation.ActiveMechanism.ActiveToolFrame.Transform.y
ActiveView.LookAt.z = ActiveStation.ActiveMechanism.ActiveToolFrame.Transform.z
tmpMatrix = RsMath_TransformToMatrix(ActiveStation.ActiveMechanism.ActiveToolFrame.Transform)
tmpVector.z = 1
tmpVector.x = 2
tmpMatrix.pos = RsMath_mult_mat_vec(tmpMatrix, tmpVector)
ActiveView.LookFrom.x = RsMath_MatrixToTransform(tmpMatrix).Position.x
ActiveView.LookFrom.y = RsMath_MatrixToTransform(tmpMatrix).Position.y
ActiveView.LookFrom.z = RsMath_MatrixToTransform(tmpMatrix).Position.z
End Sub

:+1:

Oh, and you would need a really good graphics engine to run that…

:stuck_out_tongue_winking_eye:

:nauseated_face:

I Do :imp:…

Did it work like you wanted???

Basicaly two things are holding me back.. The first thing is time, i’m doing a fairly big project now and that consumes a lot of time. And the second thing is my poor VBA-skills.. But because of the time-issue my boss won’t let me do the RS VBA course (well at least not before the summer), and i I don’t think you are allowed to “just share” course-material.. Besides that, I thought the “TCP-chasing camera” would take a lot of time to produce. So you kinda caught me by surprise when you posted a solution immediately the next day. :sunglasses:

The irony in all this is that i have to run a simulation which requires VBA, but @ work i have no time to dig into the matter.. :frowning: To that matter i’ve left you a nice (bunch of) question in the Simulation Controller-topic..

When following the TCP around at a fixed distance I got really seasick…

Well I had the RobotStudio:VBA course last week so I hope that you will have time to attend the next course in the fall.
:star:

What kind of simulation are you running by the way?

Hello John,

First of all, playing 3D games on a regular basis will get you used with the sea-sickness :clown_face: , and even if i were to get seasick it would be worth it :smile:.

Second, i can’t hardly wait to try out the “TCP chasing camera”, but @ work i don’t have the time at this moment, and @ home i haven’t got RS.. So you really made me eager to test it out :sunglasses:, but right now i can’t puzzle it out.

The third would be where to find the rad2deg-example in the RS API help-file. Well if you search the help file for “helper value” you’ll find an “Example of the KinematicModeler object”. If you select this topic you’ll find this:

Sub Kinematics()
'This sub will create two boxes which it then creates a mechanism with a torational movement between.

'Helper value for Radiants to Degrees
Dim dbDeg As Double
dbDeg = 1 / 360 * 2 * 4 * Atn(1)

And i forgot about the simulation i am (well trying to) running at this moment.

I’m simulating a small but complex universal robot roller hemming workcell which we built some time ago. An S4C+ IRB 6400R (also acting as PLC in multitasking :sunglasses:) is positioned besides a turntable and a downholder. Products (car doors, trunklids etc etc etc) can be placed on the turntable. Then the robot can randomly use up to 6 different hemming tools for the actual hemming.

But now a new part is being introduced on this workcell. And my boss wants a simulation. When i press “play” in robotstudio everything has to go automatically from the beginning until the end. Clamps, toolchanging, table-turns etc etc..

So far i’ve constructed the workcell, made all the moving parts into kinematic models (over 20 kinematic models!) and programmed the robot. These are all things i’ve done before, but to get everything moving automatically requires VBA.. And this is where i get stuck..

Today i’ve read you reply to my questions about the moving controller over and over again, and the only thing i got working was the deg2rad-part and making the turntable stop moving somewhere around the 90 degrees. I couldn’t kill the controller when the turntable has reached the 90 degrees, I couldn’t make it reach EXACTLY 90 degrees at the higher speeds i need, and so on.

I’m making this simulation an example to convince my boss to free up some of my time to be able to get the VBA course, but until then i somehow need to manage..

Hello Melk -

I have hacked around in VBA enough to “animate” some kinmatic models of my own and maybe I can look at what you have created so far and either provide good examples to accomplish what you need, or help you with your entire simulation.

Please make available somehow your station files and a breif description of the mechanisms you want to animate and interface to the robot controller and I will see what I can help with in the next couple of weeks.

I have seen this hemming cell before so I have a pretty good idea of what you are looking to do.

Tom

This discussion has been moved to the ‘How to move it’ topic to keep the JohnsBar clean with only bar stuff.

New version 1.4 with two new features.

You can find it for download on the first page.

:+1:

Hello John,

Tomorrow I’m going to try it out for sure.. It’s nice to see that your toolbar continues to develope :stuck_out_tongue_winking_eye:..