TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
All posts discussing pricing or where to buy TurboCAD will be deleted.

VBScript to replace selected objects with circles of set diameter
Read 4555 times
* November 12, 2009, 01:59:43 AM
Hi

This is a small utility to change selected objects into circles. The diameter if each replacing circle is read from the object's X size it is replacing.

I recently had to do machine toolpaths from a 3rd party's dxf where all the holes to be drilled was polylines (about 60 holes). I wrote this utility to make the task easier for me. The polyline circles was in 16 segments and the cnc router would not have cut round circles for the larger holes.

The script works in the TC macro recorder

Feel free to use, change or comment.



[attachment deleted by admin]
« Last Edit: November 12, 2009, 02:27:34 AM by pvr »

Logged


November 12, 2009, 02:47:52 AM
#1
Hi pvr,

I never used this soft routines.

How can I use this, how must I place this in TC16.1 ?
Must I place it in a subdir of TC ?

Thanks,
Marc

Logged
greetings from belgium (Pajottenland)
WIN 8.1/10 - x64
- TC 9 --> TC 16.2 / 52.0 pro Platinum
- AnimationLab 4.4 - MontageCenter 1.0
- CAM plug-in for v 16


* November 12, 2009, 11:00:58 AM
#2
Hi Marc

Download and unzip the file. You can unzip to any directory. Then under TC's View menu select MacroRecorder Palette. The Macro recorder (MR) will open. Now on the MR toolbar select open file button and go to the directory where you have unzipped this file and open it. Now select the objects on your drawing you want to change to circles and click the run button on the MR toolbar. The objects will be changed to circles. The objects should not be single lines as the diameter is read from the itmes x size. The diameter can be overridden by typing a diameter size, but then all circles will have the same size. This only works under TC Professional version and was made with TC v15 but should work with all versions from version 7.

Hope it helped and good luck.

Cheers

Piet

[attachment deleted by admin]

Logged


November 12, 2009, 01:36:58 PM
#3
Hoy Piet,

Thanks, I will try this.

Marc

Logged
greetings from belgium (Pajottenland)
WIN 8.1/10 - x64
- TC 9 --> TC 16.2 / 52.0 pro Platinum
- AnimationLab 4.4 - MontageCenter 1.0
- CAM plug-in for v 16


* June 03, 2019, 07:44:24 PM
#4
Seems like the script for this was deleted. Anyone have an example, or the original script?

Scott...

Hi

This is a small utility to change selected objects into circles. The diameter if each replacing circle is read from the object's X size it is replacing.

I recently had to do machine toolpaths from a 3rd party's dxf where all the holes to be drilled was polylines (about 60 holes). I wrote this utility to make the task easier for me. The polyline circles was in 16 segments and the cnc router would not have cut round circles for the larger holes.

The script works in the TC macro recorder

Feel free to use, change or comment.



[attachment deleted by admin]

Logged


* June 04, 2019, 12:13:36 AM
#5
Hey Scott,

Hope this helps :)

----------------------------------
' Obj2Circle.tcr
' Replace selected objects with circles of set diameter'
' To be loaded into TurboCAD's MacroRecorder and run from there

option explicit
Dim TCDwg, TCGrs
Dim Dia

Sub CreateCircle(Target)
 Dim NewCircle

 Set NewCircle = TCGrs.AddArcCenterAndPoint(0, 0, 0, Dia/2, 0, 0, 0, 0)
   
   NewCircle.MoveAbsolute Target.ReferencePoint.X, Target.ReferencePoint.Y, Target.ReferencePoint.Z
   NewCircle.Properties("PenColor") = RGB(255, 128, 64)   
End Sub

Sub Main
 Dim TCSel, Target, NewCircle, BBox

 Set TCDwg = ActiveDrawing
 Set TCGrs = TCDwg.Graphics
 Set TCSel = ActiveDrawing.Selection

   If TCSel.Count < 1 then
     MsgBox "Select some items first!"
     Exit Sub
   End If

   For Each Target in TCSel   
      Set BBox= Target.CalcBoundingBox
      Dia = BBox.Max.X - BBox.Min.X
      CreateCircle(Target)
      Target.Delete
      TCDwg.ActiveView.Refresh
   Next

   ActiveDrawing.Selection.Unselect
   TCDwg.ActiveView.Refresh
End Sub

Main

------------------------------

Copy all between the two ----------------- lines and save to a .tcr file



Piet

Logged


June 04, 2019, 05:57:17 AM
#6
Hey Scott,

Hope this helps :)

----------------------------------
' Obj2Circle.tcr
' Replace selected objects with circles of set diameter'
' To be loaded into TurboCAD's MacroRecorder and run from there

Out of curiosity, which version can use this script?  From what I have read, more recent versions cannot use Visual Basic anymore.


Jeff

Logged
TC Pro Platinum 2019, 2018, 2017, 2016 & 2015 (all with LightWorks & RedSDK) & V21
System: i7-5820K @ 3.30GHz, ASRock X99 Extreme4, 16GB DDR4-2133 RAM, Gigabyte GTX 970, Samsung NVMe SSD 950 (256GB), Windows 7 Pro (64-bit) SP1


* June 04, 2019, 08:29:39 AM
#7
Macro recorder is a "leftover" in TC and still work, maybe they have work on it resently, i think to remember a post from Shaheryar about this.
The script above here work i v 2018 at least, i dont have 2019 open at the moment, but guess it will work there aswell

Torfinn

Logged
V18, V19, V20, V21, 2015/ 16/ 17/ 18 Pro. Platinum
Deluxe V20, V21, 2015/ 16/ 17
RedSDK enabled
Windows 10 Home Premium 64 bit, 32 GB
NVIDIA Geforce GTX 780m, 1 GB