News:

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

Main Menu
TurboCAD 2026 Platinum box
Now available

TurboCAD 2026.2

The latest update for TurboCAD 2026. It installs over any 2026 build and keeps your activation, drawings and settings. Get it from the Start Page or Help > Check for Update.

Scripting Tip Wanted

Started by Jeff_in_90620, March 20, 2016, 10:12:23 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Jeff_in_90620

Saw the following RFQ on a freelancing site: "I have 7,000 drawings, I need a layer added to the drawing and have an object in the drawing changed to this new layer."

Is TurboCAD capable of this?  Because when I looked into scripting something in 2015, it was pretty limited (but that included saving a file).


Thanks in advance, 

Jeff

Jeff

TC 2026 Pro Platinum plus 2015->2024 (most with LightWorks & RedSDK) & V21
System: AMD Ryzen 9 7950X, MSI Mag X670E Tomahawk WiFi, 64GB RAM @ 4.80GHz, ARC A770 w/16GB, 3 x Samsung NVMe 990 (1TB), Windows 11 Pro (64-bit)

murray dickinson

Not entirely within TC, I'd say.   I think it more likely that AutoIT could run a batch file that would successively open the files, insert a new file that's blank except for a new layer with a name not already used in any of the files, save and close, but isolating an object already in the file and switching its layer to a new one sounds improbable.  Is it the same object in all of the files?  If so, put that in the new file to be inserted.  That would make winnowing the existing files to isolate and delete the existing same-object-on-a-different-layer in the files the difficult bit.  Are all of those 7K files the same TC version and do you want them to keep them in those versions?   

Jeff_in_90620

The person posting the RFQ was expecting AutoCAD and also didn't want to pay very much for it, so an automated technique would have been required (too many opportunities to screw up if I tried to do it manually... and without the benefit of cocaine   ;) ). 

I don't know if AutoCAD can do what he requested, but I thought I'd ask here on the off chance that it was feasible.


Jeff

Jeff

TC 2026 Pro Platinum plus 2015->2024 (most with LightWorks & RedSDK) & V21
System: AMD Ryzen 9 7950X, MSI Mag X670E Tomahawk WiFi, 64GB RAM @ 4.80GHz, ARC A770 w/16GB, 3 x Samsung NVMe 990 (1TB), Windows 11 Pro (64-bit)

murray dickinson

In that case, batch open, insert x-ref of the object, close would be how I'd do it.   The original object would still be there, but meh. 

Vlad Veselov

Quote from: Jeffin90620 on March 20, 2016, 10:12:23 PM
Is TurboCAD capable of this?
Yes.

Variant 1: Using TurboCAD SDK. You need the following skills vbscript, TC SDK/DOM.
See macropal.gif. Files in temp.zip: VBScript file (macro.tcr), source drawing (drawing1.tcw), target drawing (drawing2.tcw) with new layer.

Variant 2: Using Keystroke Macros for TurboCAD 2016’s selector. See KeyMacro.gif.
No special knowledge is required, turbocad shortcuts only.

Description and demo video: http://cadexp.com/TurboCAD/Forum/KeyMacro/Macros/ReadME.html

Feature is being tested now (available for beta users).

Keystroke Macros:
<|'1'|0|

// Open file Drawing1.tcw
    VK_MENU, 'F', 'O', VK_MENU, Sleep(900),          // Open file  dialog
    VK_CONTROL, 'A', VK_CONTROL, VK_DELETE,          // Ctrl-A, Del - clear string
    Str("H:\temp\Drawing1.tcw"),                     // Enter path for drawing
    VK_RETURN,
   
// Create new layer name = '111'
    VK_CONTROL, VK_MENU, 'O', VK_MENU, VK_CONTROL,   // call 'Drawing setup' options
    VK_SHIFT, VK_TAB, VK_SHIFT, 'L',                 // Layers page
    VK_MENU, 'P', VK_MENU, Str("111"),               // New layer name = '111'
    VK_RETURN,                                       // Ok   
    VK_MENU, 'N', VK_MENU,                           // New layer
    VK_TAB(8),    VK_RETURN,                         // Ok
   
// Select green sphere
    VK_CONTROL, 'Q', VK_CONTROL,                     // call 'selection by query' dialogue; query = 'Line Color'='Green'
    VK_RETURN,                                       // Ok   

// Set new layer
    VK_CONTROL, 'F', VK_CONTROL,                     // call 'Properties' dialogue//
    Sleep(100),
    VK_SHIFT, VK_TAB(3), VK_SHIFT,                   // focus to combo 'layers'
    Sleep(100),
    VK_END,                                          // select last layer ('111')
    Sleep(100),
    VK_TAB(4),    VK_RETURN,                         // Ok
   
// Save/Close drawing
    VK_CONTROL, 'S', VK_CONTROL,                     // Ctrl-S
    VK_CONTROL, VK_F4, VK_CONTROL                    // Ctrl-F4
|>


Vlad


Jeff_in_90620

Wow.  Sure looks pretty powerful.

I wonder if this would work inside a shell that ran external to TurboCAD and presented each of the 7,000 files to TC one at a time for the required modifications.


Jeff

Jeff

TC 2026 Pro Platinum plus 2015->2024 (most with LightWorks & RedSDK) & V21
System: AMD Ryzen 9 7950X, MSI Mag X670E Tomahawk WiFi, 64GB RAM @ 4.80GHz, ARC A770 w/16GB, 3 x Samsung NVMe 990 (1TB), Windows 11 Pro (64-bit)

colinreid

Gosh.  Where did that come from?

And where in the Helpfile is there any reference to Keystoke Macros or turbocad shortcuts.

Are there any helpful references to be able to get started with this method?
regards
Colin Reid
TC2018 Pro Platinum 64 bit  + LW plugin on Win10 desktop and  Quad Intel i7 with 32GB RAM + 128GB  SSD and 2TB partitioned hard disk, NVidia 2GB video

Vlad Veselov

Colin,

Quote from: colinreid on April 06, 2016, 04:18:18 AM
turbocad shortcuts.

Pease see: https://www.google.ru/?gws_rd=ssl#newwindow=1&safe=active&q=turbocad+shortcut+keys
or use 'help\keyboard' option (tckeys.png; Selector+App.txt).

Quote from: colinreid on April 06, 2016, 04:18:18 AM
Keystoke Macros
This functionality is available now for beta users only.

Vlad

murray dickinson

If the assumption that the object can be found by the same query in each file is valid, AutoIT could do it, I think, with most TC versions.