News:

When replying to a specific statement be sure to quote the previous post.

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.

Help with 'Block' editing

Started by PCSteel, March 20, 2024, 09:29:18 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

PCSteel

I have around 250 2D blocks that I want to convert from imperial to metric, which means I need to scale them all by 25.4 (x & y). I have tried to record a 'Macro' of the 'Edit Content' of a block but haven't had any success.
Does anyone have any suggestions of how I should approach this?

Cheers
John
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

DonCW

Quote from: PCSteel on March 20, 2024, 09:29:18 PMI have around 250 2D blocks that I want to convert from imperial to metric, which means I need to scale them all by 25.4 (x & y). I have tried to record a 'Macro' of the 'Edit Content' of a block but haven't had any success.
Does anyone have any suggestions of how I should approach this?

Cheers
John

I found a reasonably easy method, highlight all the imperial blocks you want to convert and and click the copy command. Open a new metric drawing and paste all the blocks. I have a business doing shop drawings for the cabinet industry, I set the precision quite low and round off to 'one' which is close enough for my needs.
DonCW
2020 Platinum
2018 Platinum
2017 Pro with Light Works Plug in



Windows 10
There's so much to learn and not much time left to learn it.

nikkipollard

#2
I would use Dons Method.
I thought I could try a script in the macro recorder- It should be easy right? WRONG.
First the scale was way off. I fixed that , but temporarily the blocks in the drawing can't be selected.
Which is probably just another line of code. It will take a bit of experimenting to fix that. (Or someone who knows the answer can help.)
However blocks dragged from the block palette work as expected. The reference point is in the right place and the blocks are in the right size.
Close the drawing and opening it again - The blocks can be selected.  - Quite painful. I have tried everything I can think of nothing works.
Option Explicit
 
'====================================================================
   '# DESCRIPTION

'=====================================================================
Dim tcDraw


Call Main


'_______________________________________________________________________________
Sub Main
     
Dim BLKS
Dim BLK
Dim vxAnchor
Dim gfxs
Dim gfx

'All the blocks in the drawing
Set BLKS = ActiveDrawing.Blocks

For Each BLK In BLKS
' insertion point of the block
Set vxAnchor = BLK.Anchor
'All the graphics in the block definition
Set gfxs = BLK.Graphics
'Scale(scalex,Scaley,Scalez,refx,refy,refz)
'the scale is out when scaled before moving the graphics to 0,0
'The reference x,y and  don't seem to make a difference with the Graphics.Scale  method
Call gfxs.MoveAbsolute(0,0,0,vxAnchor.X,vxAnchor.Y,vxAnchor.Z)
Call gfxs.Scale(25.4,25.4,25.4,0,0,0)
Call gfxs.MoveAbsolute(vxAnchor.X,vxAnchor.Y,vxAnchor.Z,0,0,0)
Next
 
ActiveDrawing.ActiveView.Refresh

End Sub



Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

PCSteel

I'm not getting anywhere with that Don. When I select more than one block in the Blocks Pallet, the copy button is greyed out. In fact, I don't get the copy button at all. If I select a single block and hit the copy button, it opens the 'Create Block' window.
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

PCSteel

Thanks for trying Nikki. It sounded like a simple task, but I have very little experience with Macros.
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

Jeff_in_90620

Quote from: PCSteel on March 20, 2024, 11:13:13 PMWhen I select more than one block in the Blocks Pallet, the copy button is greyed out.

Do not do this in the Blocks palette.  Place at least one copy of each Block item that you want to copy into Model space.  Select all of them, copy and paste into a new drawing that uses a Metric template.  The Block definitions will be converted and copied into the new palette as well.


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)

PCSteel

Thanks Jeff, I'll give that a try in the morning. Busy ATM getting grandchildren to bed.
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

Alvin Gregorio

#7
Quote from: PCSteel on March 20, 2024, 09:29:18 PMI have around 250 2D blocks that I want to convert from imperial to metric, which means I need to scale them all by 25.4 (x & y). I have tried to record a 'Macro' of the 'Edit Content' of a block but haven't had any success.
Does anyone have any suggestions of how I should approach this?

Cheers
John
Do all the Blocks exist in the same Drawing file?  Or are they each in a separate Drawing file?

If the first, just change the Space Units System of the Drawing file.  With the option "Convert units after alteration" ticked.
Alvin Gregorio
TurboCAD: v2024_Plat (31.0.77.1); v2022_Plat; v2020_Plat; v2019_DL; v20.2_PP
Lenovo Thinkpad P20Y laptop; Windows 11 Pro; i7-11800H 2.30GHz, 8-core; 32GB RAM; NVIDIA T1200
3D_Printer: Ender-3 S1 (NOT Pro)

DonCW

Quote from: PCSteel on March 20, 2024, 11:13:13 PMI'm not getting anywhere with that Don. When I select more than one block in the Blocks Pallet, the copy button is greyed out. In fact, I don't get the copy button at all. If I select a single block and hit the copy button, it opens the 'Create Block' window.

Sorry, as usual on my part the explanation isn't very good. First step is to move the blocks into model space and then you should be to highlight and copy them all.
DonCW
2020 Platinum
2018 Platinum
2017 Pro with Light Works Plug in



Windows 10
There's so much to learn and not much time left to learn it.

PCSteel

Thanks everyone for the suggestions. It looks like when I created all these blocks, I got the scaling wrong and will need to scale them all and re-save them.
I have created all these items as 'symbols' in my 2D software over many years and some time ago, converted them to blocks for use in TurboCAD but I don't recall how I did this but must have got it wrong at the time. For example, when I place something that should measure 100mm into a metric drawing it comes in at 3.937mm. I have known about the scaling issue and therefore when I use one in a model, I scale it when I place it.
Thinking about it now, I probably placed all these items in a drawing in my 2D software and exported the file to DWG before opening it in TC and must have had my export settings wrong.
I have a bit of spare time at the moment so I might just scale and re-save them all.
Thanks again for the help.

John
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

DonCW

Quote from: PCSteel on March 21, 2024, 12:58:10 PMThanks everyone for the suggestions. It looks like when I created all these blocks, I got the scaling wrong and will need to scale them all and re-save them.
I have created all these items as 'symbols' in my 2D software over many years and some time ago, converted them to blocks for use in TurboCAD but I don't recall how I did this but must have got it wrong at the time. For example, when I place something that should measure 100mm into a metric drawing it comes in at 3.937mm. I have known about the scaling issue and therefore when I use one in a model, I scale it when I place it.
Thinking about it now, I probably placed all these items in a drawing in my 2D software and exported the file to DWG before opening it in TC and must have had my export settings wrong.
I have a bit of spare time at the moment so I might just scale and re-save them all.
Thanks again for the help.

John
If possible could you save a few of the blocks to v20 and post them.
DonCW
2020 Platinum
2018 Platinum
2017 Pro with Light Works Plug in



Windows 10
There's so much to learn and not much time left to learn it.

Alvin Gregorio

Quote from: PCSteel on March 21, 2024, 12:58:10 PMThanks everyone for the suggestions. It looks like when I created all these blocks, I got the scaling wrong and will need to scale them all and re-save them.
I have created all these items as 'symbols' in my 2D software over many years and some time ago, converted them to blocks for use in TurboCAD but I don't recall how I did this but must have got it wrong at the time.
For example, when I place something that should measure 100mm into a metric drawing it comes in at 3.937mm. I have known about the scaling issue and therefore when I use one in a model, I scale it when I place it.
Thinking about it now, I probably placed all these items in a drawing in my 2D software and exported the file to DWG before opening it in TC and must have had my export settings wrong.
I have a bit of spare time at the moment so I might just scale and re-save them all.
Thanks again for the help.

John
It's not a conincidence that the factor is 3.937.  There are 39.37 Inches in a Meter.
I think this can all be handled through the Space Units option.  With varying settings for "Convert units after alteration".
If you can somehow share the with us-- v2022.tcw or earlier for me, v2020.tcw or earlier for DonCW-- we can probably fairly quickly work it out for you.
Maybe Link us to where you have them stored?

You didn't answer-- are all these Blocks now gathered in one .tcw file?  Or are they each in their own individual file?
Alvin Gregorio
TurboCAD: v2024_Plat (31.0.77.1); v2022_Plat; v2020_Plat; v2019_DL; v20.2_PP
Lenovo Thinkpad P20Y laptop; Windows 11 Pro; i7-11800H 2.30GHz, 8-core; 32GB RAM; NVIDIA T1200
3D_Printer: Ender-3 S1 (NOT Pro)

PCSteel

Thanks Don & Alvin. Currently holding one of five week old twins. Will attach a sample when I have two hands.  :D
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

PCSteel

Attached is one of the blocks as requested. It should measure 100mm overall in both directions.
Alvin, the blocks are in a template file.You cannot view this attachment.
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

PCSteel

Sorry, I forgot to save that file back to an earlier version so here's a 2021 version.You cannot view this attachment.
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

nikkipollard

#15
Ah so they are all in different Files.
This is exactly what vbscript was designed for.
The code I shared will work. But you would want to modify it so that it opens each file in a folder, scales the block definition and then closes the file.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

PCSteel

Nikki, that script worked flawlessly. Thank you so much for the time you have put into it. I'll do them in batches of 20 or 30 and it will go very quickly. Thanks again!

John
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

PCSteel

And I didn't even need to do that because I didn't realise that running the script fixed all the blocks, not just the ones that I had dragged into model space. Brilliant, thanks so much Nikki.
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

Alvin Gregorio

#18
I like to use the Space Units method, when it's applicable.
Seems more holistic.

In your file with mis-scaled Blocks (which can be done to the Template file with all the Blocks in it)
>Change Space Unit System to English, with "Convert units after alteration" not ticked; then
>Change Space Unit System to Metric, with "Convert units after alteration" ticked

>set Space Units Units_in_Workspace as desired, such as mm, precision=6
__________________
(the Title Blocks, which probably correctly existed within the Template file before the other Blocks were imported, will have to be scaled manually)

===================================================================================================

It's really cool how Nikki taught herself all this useful script-writing stuff.
-
-
Alvin Gregorio
TurboCAD: v2024_Plat (31.0.77.1); v2022_Plat; v2020_Plat; v2019_DL; v20.2_PP
Lenovo Thinkpad P20Y laptop; Windows 11 Pro; i7-11800H 2.30GHz, 8-core; 32GB RAM; NVIDIA T1200
3D_Printer: Ender-3 S1 (NOT Pro)

PCSteel

Quote from: Alvin Gregorio on March 22, 2024, 04:32:07 AMI like to use the Space Units method, when it's applicable.
Seems more holistic.

In your file with mis-scaled Blocks (which can be done to the Template file with all the Blocks in it)
>Change Space Unit System to English, with "Convert units after alteration" not ticked; then
>Change Space Unit System to Metric, with "Convert units after alteration" ticked

>set Space Units Units_in_Workspace as desired, such as mm, precision=6
__________________
(the Title Blocks, which probably correctly existed within the Template file before the other Blocks were imported, will have to be scaled manually)

===================================================================================================


Thanks Alvin, I'll give that method a try with the template on my PC when I get home in a couple of weeks.


Quote from: Alvin Gregorio on March 22, 2024, 04:32:07 AMIt's really cool how Nikki taught herself all this useful script-writing stuff.
-
-

I agree, very clever!
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3

PCSteel

I just remembered that I had an earlier version of that template file in my laptop Alvin, so I tried your method with it. It worked perfectly also thanks, which proves again, there's always more than one way of doing things in TurboCAD.
John@PC Steel

Core i7-6700 CPU
16GB Ram
64 Bit
Windows 10 Home
TurboCAD 2015 Pro Platinum 64 bit Build 90.0
TurboCAD 2023 Platinum 64 bit Build 63.3