TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Remember to do a search before you ask a question!!!

Inserting blocks and snapping them to walls
Read 571 times
* August 09, 2018, 12:31:25 AM
I'm currently inserting blocks with the following code

TurboCAD.ActiveDrawing.graphics.AddBlockInsertion(BlockName, X, Y, Z)

everything works works fine except the blocks don't snap onto the walls as they do when you insert them from the block pallet.

as a work around if you manually resize them they will snap to the wall but id like a way to do it with code. if anyone has an idea how i can achieve this that would be great

thanks grimbot

Logged


August 09, 2018, 02:05:41 AM
#1
Are you setting the Workplane before placing the objects?


Jeff

Logged
TC Pro Platinum 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


* August 10, 2018, 05:49:48 AM
#2
Try posting this in the problem section too. I think more people read that and maybe someone would be able to help.
You might want to say which programming language you are using. How the walls were created ie if they are part of the program you are writing or if they are already in the drawing.
 I know Torfinn uses ppm to draw whole buildings but I dont think he uses true walls.

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 16, 2018, 12:41:50 AM
#3
I'm not quite sure where or how to set the workplane. I'm drawing in 2D as you can see in the attached image. the door on the left was added manually and the door on the right was added with my code. I'm using AutoHotkey to program in but an example in any language will do and i can translate it

Logged


* August 16, 2018, 08:05:15 AM
#4
I don't know anything about external programs but I do use ppms for all my architectural symbols including doors and windows.
You might want to try PPMs because
A PPM will attach itself to a wall if dragged from the library directly onto the wall .
You can  copy PPMs by dragging them onto the wall and holding down the ctrl key
I have never used blocks in a ppm but there is a method to use them - although I don't know if a ppm with a block will attach itself to a wall , ( I script the whole window so that it is parametric) but you could try. 
I also havent tried moving the window away from the reference programatically, or more then 1 window per symbol. maybe Torfinn has.
or you could experiment.
https://turbocaddoc.atlassian.net/wiki/spaces/TG/pages/176982592/Parametric+Part+Script+Editing

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 16, 2018, 08:29:32 AM
#5
A PPM cant use Blocks in TC as there we have ppm v 1, ppm v 2 can use Blocks but then it has to be by SD ( Symbol Designer ) that we can save as a dwg and import to TC.
I know it say we can in the ppm section in helpfile, but we dont, Dean and i tested some years ago and we got it confirmed i think to remember that it not work
A ppm v2 with Blocks will fail in TC as TC dont know how to handle it.

The reason for we can insert door/ window to walls in TC is the AUX we got 2-3 years ago ( still best Christmas gift ever :)

So what grimbot try to do with the code, i dont think it's possible beacause all the Architect tools are "special" in lack of a better word for it :)
But if you only work in 2D, have you try'd with Double/ Multiple line's, or is that what you already use ??

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


* August 16, 2018, 09:56:58 PM
#6
Good to know Torfinn

Is the only purpose of your program to position a door a specific distance from another door?
 Have you tried the doors in the architectural menu? 
Or is there a reason you would prefer to use a block?

« Last Edit: August 16, 2018, 10:11:00 PM by nikkipollard »

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 17, 2018, 12:15:20 AM
#7
I still cant get TC to read symbols created using sd2
So I experimented
It seems that a Static symbol will work but not a block.
They do attach to the walls but they don't cut the wall so you need to use some sort of a mask

Units (1[mm])
M=Parameter("distance",1500,LINEAR)
W=Parameter("wall",230,LINEAR)

w1=900 //static symbol width

S = StaticSymbol("Door1.tcw");
mask=SetProperties(Rectangle(w1,W+5),"brushStyle"= "Solid","PenColor" = 0xffffff,
      "layer"="whipeout");

L1=Polyline(Point(-w1/2,-W/2),Point(-w1/2,W/2))
L2=Move(L1,900)
d2=IF(M==0,0,IF(M<0,-w1/2,w1/2))
mo=Move(Group(mask,S,L1,L2),M+d2)

pr = RefPoint(0,0,0);
Output(pr,mo)

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 17, 2018, 12:37:16 AM
#8
Yes, Static works
And Block in v2 will not cut out in a wall i beleve as there are no Architect walls to use in SD
My need for Blocks in ppm was the rooftile's basically as i have 1275 tiles on my standard testhouse and since TC draw them one by one, it takes some time :)

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


* August 17, 2018, 02:21:49 AM
#9
The static symbol is imported as an exref doesn't that work the same as a block??

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 17, 2018, 02:51:06 AM
#10
Yes and no i guess :)

1 static in and then copied x times in roof "X and Y" takes longer time then make 1 block with ppm, copy the Block to a row in X x times, make that row to a Block and copy that in x times Y direction inside the ppm.

It's when it come over about 500 the time start to run.
I have a grating ppm, a plate 1,2 x 4 meter and 10 000 holes, take about 36 min to finish :)
On my old machine 106 min, in the beginning i believed i did something wrong and "kill" tc many times before by luck i let it run for a long time, when coming back to pc, dang it did work :)

Torfinn

Edit;
I forgot, a static cant change size, different tiles/ different size's
« Last Edit: August 17, 2018, 03:11:36 AM by 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


* August 18, 2018, 01:46:58 AM
#11
And that is the whole point of ppm. Which is the reason I don't know that much about static symbols

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 18, 2018, 11:03:18 PM
#12
I've been doing a bit more investigating. It Seems when the Block is snapped to the Wall 2 TieSets are created, one between the block and the wall, and one between the wall and the block. I can't seem to figure out how to create my own TieSets to do the same thing. If anyone has any ideas that would be great.

;create Wall
WallGraphic := turboCAD.activeDrawing.Graphics.Add("", "TCW60Wall")
Vertices := WallGraphic.Vertices
Vertices.add(-5, 0, 0)
Vertices.add(5, 0, 0)
;Create Block
newblock := TurboCAD.ActiveDrawing.Graphics.AddBlockInsertion("ddoor10_2013", 0, 0, 0)
TurboCAD.Activedrawing.ActiveView.refresh

----Need to create the tieSets here but can't figure out how to


Logged


* August 19, 2018, 10:48:33 PM
#13
I don't think you can, even TC windows need to be dragged directly onto the wall. There is no way, that I know of, to link afterwards.
However in 2d I would just fake it with a mask , IE a solid white hatch in the block(send to back)- that is the way I worked in autocad.
The only problem would be the auto aligning.
PPms can be dragged onto the wall, automatically  link to the wall and align with the wall. They just don't cut in 2d.
Can you do something similar with your program?
« Last Edit: August 19, 2018, 11:01:52 PM by nikkipollard »

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 22, 2018, 03:43:29 PM
#14
Figured it out example code below. The 11 and 7 from the TieSets.Add  call where from trial and error

WallGraphic := turboCAD.activeDrawing.Graphics.Add("", "TCW60Wall")
Vertices := WallGraphic.Vertices
Vertices.add(-5, 0, 0)
Vertices.add(5, 0, 0)
;Create Block
newblock := TurboCAD.ActiveDrawing.Graphics.AddBlockInsertion("ddoor10_2013", 0, 0, 0)

newTie := TurboCAD.Activedrawing.TieSets.Add("smart.Connection.1",WallGraphic,newblock,11,0)

newTie := TurboCAD.Activedrawing.TieSets.Add("smart.Connection.1",newblock,WallGraphic7,0)

Logged


* August 23, 2018, 02:22:52 AM
#15
Awesome.
How do you know the exact coordinates to place the block and which wall it will attach to?
« Last Edit: August 23, 2018, 02:24:53 AM by nikkipollard »

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 23, 2018, 08:44:43 PM
#16
TurboCAD will work that out you just pass in the block and the wall you want it to snap to and turboCAD will move the block onto the wall

Logged


* August 25, 2018, 01:03:01 AM
#17
I am not sure I understand. I thought you wanted to place the block using a coordinate so that it was a specific distance from another block.
I am interested in learning this .
Could you break down what each line in your code does specifically the first few lines.
Thank you in advance.
 
« Last Edit: August 25, 2018, 01:13:01 AM by nikkipollard »

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks


* August 31, 2018, 05:56:23 PM
#18
//create a wall for the block to attach to.(you can also use an existing wall in the drawing aswell)

WallGraphic := turboCAD.activeDrawing.Graphics.Add("", "TCW60Wall")    //This creates a new graphic in turboCAD with the TCW60Wall RegenMethod. the standard wall in turboCAD
Vertices := WallGraphic.Vertices   //  This is the vertex collection of the newly created graphic
Vertices.add(-5, 0, 0)  //  this is the starting position of the wall
Vertices.add(5, 0, 0)  //  this is the end position of the wall

//So after the above code there is a wall going from x-5, y0 to x5, y0

;Create Block

newblock := TurboCAD.ActiveDrawing.Graphics.AddBlockInsertion("ddoor10_2013", 0, 0, 0) // this line inserts the block "ddoor10_2013" into the drawing at x0 y0 z0

newTie := TurboCAD.Activedrawing.TieSets.Add("smart.Connection.1",WallGraphic,newblock,11,0)
newTie := TurboCAD.Activedrawing.TieSets.Add("smart.Connection.1",newblock,WallGraphic7,0)
// the above 2 lines create the link between the wall graphic and the block graphic. if the block graphic is not positioned on the wall turbocad will move the block to the closest point on the wall for you.

I use the same block over and over again so my goal with this was to insert a block at the current mouse position using a shortcut key so i didn't have to keep dragging it over from the blocks pallet

Logged


* September 03, 2018, 07:03:20 AM
#19
That makes sense thank you.
It is interesting to see what can be done with the SDK.
I would have just used the opening tool with a preset.

Logged
Nikki
TC20 platinum
TC 2015 platinum
TC 2017 with lightworks