Revit API: Direction of rebar spacing (Python) - revit-api

I'm trying to multiply rebar in a slab using following methods:
(using Python script)
doc = DocumentManager.Instance.CurrentDBDocument
RS = Autodesk.Revit.DB.Structure
RebarType = MyRebarType
slab = MySlab
norm = XYZ(0,0,1)
bar = MyCurve
n = MyQuantity
s2 = RebarSpacing
hook_type = None
rebar = RS.Rebar.CreateFromCurves(doc,RS.RebarStyle.Standard,RebarType,hook_type,hook_type,slab,norm,bar,RS.RebarHookOrientation.Right,RS.RebarHookOrientation.Left,True,True)
rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_LAYOUT_RULE).Set(3)
rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS).Set(n)
rebar.get_Parameter(BuiltInParameter.REBAR_ELEM_BAR_SPACING).Set(s2)
The problem is that i cant define direction of my rebar spacing. It depends on rebar position in my slab.
Here is an example of how this code creates rebars
Any help would be appreciated.
Thank you

Just need to add one line:
rebar.GetShapeDrivenAccessor().BarsOnNormalSide = True

Related

Border/Fill Around Strip Chart Points

Question
I know this question (or similar questions) have been posted, though I cannot seem to find what is going on.
I am doing a strip chart and I have tried using both geom_jitter(position = position_jitter(0.065)) and geom_point(position = position_jitter(0.065)), but I cannot seem to put a border around each of my points.
I have been only able to fill them with a colour, regardless of whether I use fill = or colour =.
Code:
ggplot(Titanic.Data, aes(x = as.factor(Survive),
y = Age,
colour = Survive)) +
geom_jitter(position = position_jitter(0.065)) +
labs(x = "Survive",
y = "Age",
title = "Strip Chart of Age vs Survive") +
scale_colour_manual(values = c("DarkBlue", "DarkRed")) +
theme_test() +
theme(plot.title = element_text(hjust = 0.5,
face = "bold",
size = 18)) +
theme(legend.position = "none")
Graph:
Here is what the graph will look like
Code
The data set is huge, and I do not know how to add the file to this thread so here is a small portion of it.
Titanic Data

get facemesh position and rotation in world

I am trying to develop a filter where you have to eat elements in screen. My problem is that I cannot find the way to get the facemesh position and rotation in the world so that way I can compare the coordinates of facemesh with coordinates of the elements to eat. I try with worldtransform but allways returns 0 for my mesh. Is there any way to do that?
thanks so much
I don't know your scene tree configuration. Assuming you have everything inside Focal Distance
const FaceTracking = require('FaceTracking');
const Scene = require('Scene');
const R = require('Reactive');
const face = FaceTracking.face(0);
const focalDistance = -Scene.root.find('Focal Distance').transform.z.pinLastValue();
const mouthFocal = face.cameraTransform.applyTo(face.mouth.center).add(R.point(0, 0, focalDistance));
Adding focalDistance to Z is for transformation from Camera space.

Delete meshgrid points between a bounding box points

I am looking for an efficient way to delete points of a meshgrid that comes inside the bounding box of blocks (block 1 and 2 in the code). My Code is:
x_max, x_min, y_max, y_min = 156.0, 141.0, 96.0, 80.0
offset = 5
stepSize = 0.2
x = np.arange(x_min-offset, x_max+offset, stepSize)
y = np.arange(y_min-offset, y_max+offset, stepSize)
xv, yv = np.meshgrid(x, y)
#bounding box (and pints inside) that I want to remove for mesh
block1 = [(139.78, 86.4), (142.6, 86.4), (142.6, 88.0), (139.78, 88.0)]
block2 = [(154.8, 87.2), (157.6, 87.2), (157.6, 88.8), (154.8, 88.8)]
As per one of the answer, I could generate the required result if I have only one block to be removed from the mesh. If I have multiple blocks then it won't work. What could be the optimized way to remove multiple blocks from mesh grid. The final figure should look like this:
Mesh
Edit: Improved questions and edited code.
Simply redefine your x and y around your block:
block_xmin = np.min(block[:,0])
block_xmax = np.max(block[:,0])
block_ymin = np.min(block[:,1])
block_ymax = np.max(block[:,1])
X = np.hstack((np.arange(x_min-offset, block_xmin, stepSize), np.arange(block_xmax, x_max+offset, stepSize)))
Y = np.hstack((np.arange(y_min-offset, block_ymin, stepSize), np.arange(block_ymax, y_max+offset, stepSize)))
XV, YV = np.meshgrid(X, Y)
I think I figured it out based on the explanation of #hpaulj (I cannot up-vote his suggestions as well probably due to low points). I can append blocks in allBlocks array and then run a loop over allBlocks an simultaneous disabling the points in mesh. Here is my solution:
x_new = np.copy(xv)
y_new = np.copy(yv)
ori_x = xv[0][0]
ori_y = yv[0][0]
for block in allBlocks:
block_xmin = np.min((block[0][0], block[1][0]))
block_xmax = np.max((block[0][0], block[1][0]))
block_ymin = np.min((block[0][1], block[1][1]))
block_ymax = np.max((block[0][1], block[3][1]))
rx_min, rx_max = int((block_xmin-ori_x)/stepSize), int((block_xmax-ori_x)/stepSize)
ry_min, ry_max = int((block_ymin-ori_y)/stepSize), int((block_ymax-ori_y)/stepSize)
for i in range(rx_min,rx_max+1):
for j in range(ry_min,ry_max+1):
x_new[j][i] = np.nan
for i in range(ry_min,ry_max+1):
for j in range(rx_min,rx_max+1):
y_new[i][j] = np.nan

Making a randomly generated 2d map in python is taking too long to process all of the map generation

import random
l = "lava"
d = "dessert"
f = "forest"
v = "village"
s = "sect"
w = "water"
c = "city"
m = "mountains"
p = "plains"
t = "swamp"
map_list = [l,d,f,v,s,w,c,m,p,t]
map = []
for i in range(50):
map.append([])
def rdm_map(x):
for i in range(50):
map[x].append(random.choice(map_list))
def map_create():
x = 0
while x <= len(map):
rdm_map(x)
x + 1
map_create()
print(map[2][1])
I'm not getting anything for output not even an error code.I'm trying to create a randomly generated game map of descent size but when i went to run it nothing happened i'm thinking since my computer isn't that great its just taking way to long to process but i just wanted to post it on here to double check. If that is the issue is there a way to lessen the load without lessening the map size?
You have the following bugs:
Inside the map_create you must change x + 1 to x += 1. For this reason your script runs for ever.
After that you should change the while x <= len(map): to while x < len(map):. If you keep the previous, you will get a Index Error.
In any case, your code can be further improved. Please try to read some pages of the tutorial first.

solving a matrix 2x2 Shell script for?

I was wondering if there is any way to solve a matrix 2x2 using shell script in Linux. I have created a simple code using Matlab and would like to to the same using shell script. The Matlab code is as follows;
R = 0.509515;
R1 = 0.559467;
R2 = 0.579594;
L = 0;
L1 = -0.08568;
L2 = 0.13974;
y = [R1-R;R2-R];
x = [L1^2 L1;L2^2 L2];
c = x\y;
Also, is there any way to create a linspace like that in Matlab for the following command;
x=linspace(L1,L2,20)
Thanks in advance for the kind help.

Resources