Author Topic: Resize to video format  (Read 3787 times)

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6133
    • View Profile
    • Cambam V1.0 French Doc
Resize to video format
« on: October 20, 2011, 00:41:33 am »
Hello,

Another exploration of VB script  ;)

this script resize the main window to selected size.

the goal for me is to get quickly standard video and picture size for capture (doc & tuto)

++
David

Offline 10bulls

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 2164
  • Coding Jedi
    • View Profile
    • www.cambam.info
Re: Resize to video format
« Reply #1 on: October 20, 2011, 07:48:51 am »
Attached is a plugin I wrote a little back to do just this sort of thing...

It adds a new menu item to the Plugins menu called 'Script-o-matic'.

When you run it, not much seems to happen, but it has created a VBScript and placed it on the clipboard.

Then use Script - New - VBScript and paste the clipboard (CTRL+V), replacing any default script.

The resulting script will restore the 'State' of the current CamBam session, including:

. Set the CamBam screen size, tree width, property grid height etc
. Set the current colours
. Load the file currently open
. Apply the current drawing view zoom and rotation.
. Select any objects currently selected
. Set view state (axis,grid) etc.

So if you save the script and run it at a later date, it should restore the state of the CamBam view when you took the 'snapshot' script.

You can also edit the script to change the screen size for video etc.

The resulting scripts may also provide a useful example for people wanting to get into CamBam scripting.

NOTE:  This plugin will only work with the recent development releases (0.9.8k onwards).

I hope this helps!

Here is an example script output from the plugin:

Code: [Select]
sub main
    dim fm as FormMetrics = new FormMetrics()
    fm.Height = 881
    fm.Name = "CamBamMain"
    fm.Width = 995
    fm.WindowState = 0
    ' fm.XPos = 529
    ' fm.YPos = 256
    fm.UserMetrics.Add(78)
    fm.UserMetrics.Add(258)
    fm.UserMetrics.Add(324)
    dim cbm as IFormMetrics = ThisApplication.TopWindow
    cbm.ApplyMetrics(fm)
    dim xgm as XPropertyGridMetrics = new XPropertyGridMetrics()
    xgm.ColumnWidth = 168
    xgm.GroupProperties = True
    xgm.InfoHeight = -1
    xgm.ShowAdvanced = False
    xgm.ShowInfo = False
    CamBamUI.MainUI.ObjectProperties.ApplyMetrics(xgm)
    CamBamUI.MainUI.OpenFile("C:\CamBam\heart-shaped-box.cb",true)
    CamBamUI.MainUI.CADFileTree.ReloadTree()
    CamBamUI.MainUI.SysTabs.SelectedTab = 0
    CamBamConfig.Defaults.CutWidthColor = Color.FromArgb(255,255,165,0)
    CamBamConfig.Defaults.GridColor = Color.FromArgb(255,65,65,65)
    CamBamConfig.Defaults.SelectColor = Color.FromArgb(255,255,0,0)
    CamBamConfig.Defaults.ToolpathArcColor = Color.FromArgb(180,0,220,0)
    CamBamConfig.Defaults.ToolpathLineColor = Color.FromArgb(180,50,160,255)
    CamBamConfig.Defaults.ToolpathRapidColor = Color.FromArgb(255,255,69,0)
    CamBamConfig.Defaults.ViewBackgroundColor = Color.FromArgb(255,50,50,60)
    CamBamConfig.Defaults.ViewTextColor = Color.FromArgb(255,255,255,0)
    dim vxm as Matrix4x4F = new Matrix4x4F(12.1533780211962,0,0,0,0,12.1533780211962,0,0,0,0,12.1533780211962,0,-6.1332343648246E-05,5.75121972917714,0,1)
    CamBamUI.MainUI.ActiveView.ViewTransform = vxm
    dim esel(0) as object
    esel(0) = CamBamUI.MainUI.ActiveView.CADFile.FindPrimitive(4)
    CamBamUI.MainUI.ActiveView.Selection.Clear()
    CamBamUI.MainUI.ActiveView.Selection.AddRange(esel)
    dim obs(0) as object
    obs(0) = CamBamUI.MainUI.ActiveView.CADFile.FindPrimitive(4)
    CamBamUI.MainUI.ActiveView.DrawingTree.SelectObjects(obs)
    CamBamUI.MainUI.ObjectProperties.SelectedObjects = obs
    CamBamConfig.Defaults.ViewAxis = False
    CamBamConfig.Defaults.ShowGrid = False
    CamBamConfig.Defaults.SnapToGrid = False
    CamBamConfig.Defaults.SnapToPoints = True
    CamBamConfig.Defaults.ReloadTreeAfterScript = false
    CamBamConfig.Defaults.SaveSettingsOnExit = false
end sub

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6133
    • View Profile
    • Cambam V1.0 French Doc
Re: Resize to video format
« Reply #2 on: October 20, 2011, 14:33:21 pm »
Hello Andy

Thanks for this plugin  :D ... I will certainly be very useful for me, booth for making doc and for learning VBScript !

A question:

Is there a way to "autostart" a script ? 

What I want to do is: when I open a script file, it run immediately without displaying the script windows and without need to hit F5 ?

++
David