TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Interested in some really terrific mobile apps? Visit www.turboapps.com for details.

Inserting blocks and snapping them to walls
Read 142 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 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 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 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