How to use Revit API to create a structural wall? - revit-api

I already know how to create a Architectural wall using Revit API.
The code is something like this. Notice, I am also use Revit Python Wrapper in my code.
def create_wall(a, b, c, d, e, f, g, h):
doc = revit.doc
with rpw.db.Transaction('Test Is Instance') as t:
start_point = XYZ(a, b, c)
# convert millimeter to feet, internal, it uses feet
end_point = XYZ(d, e, f)
# Wrapper Line
line = Line.new(start_point, end_point)
levels = db.Collector(of_class='Level')
level_0 = levels.get_first()
wall = DB.Wall.Create(doc, line.unwrap(), level_0.Id, False)
w = db.Wall(wall)
# convert the mm to feet.
w.parameters['Base Offset'].value = g
w.parameters['Unconnected Height'].value = h
After I did this, I found it is working well. But there is one thing, the wall I created using this function, when it comes across a wall in the intersection, if there is a small gap, for example 45 mm, it will automatically stick to the wall in the intersection and the gap disappears.
Say, I created a wall 1.5 meters long, but there is anothter wall in the intersection and there is a 45 mm distance between this created wall and the existing wall in the intersection. The 45 mm gap disappears and the length of the created new wall actually 1.5 meters plus 45 mm long. And this is not what I want.
Someone told me I can use structural wall instead Architectural wall. The way to do that is to follow this step,
In menu - Structure, choose the Component in the ribbon of structure menu, then click the model-in-place, after that, there will be a window pop up, Then choose the Family Category - Walls with filter list is Structure, Then in Project Brower tree, Families - walls there will be new type of wall, and this wall doesn't have the issue I mentioned above, that is it won't automatically strectch and change the length when I create the wall.
First topic is that is this true? What are their differences for these two types of wall creation? And if this is true, how can I use revit API to create the second type of wall?
PS. I also use Revit Python Shell to inspect two different kinds of walls. The first type of wall - Architectural wall type is Wall class in Revit API. I also have the second type of wall handy, but it's created manually, it's created by someone else and not created by Revit API. I inspected the revit file containing the second type of wall, when I select this second type of wall in his Revit file, the return type of selected Revit wall in Revit python shell is FamilyInstance.
Secondly, I have this question, why the first type of the wall is Wall Class but the type of the second wall - structural wall is FamilyInstance.

I think what the wall you create through the revit-api does, is that it is joining the wall end to another wall.
What you need is WallUtils.DisallowWallJoinAtEnd().
As stated in the revit-api documentation. revitapidocs.com - WallUtils

Related

Godot Script does not delete child nodes as expected

I am creating a small space shooter game with asteroids set up as Rigid Bodies. They just fall past the bottom of the screen and are then meant to be deleted and that's the part I am having trouble with. I have a print function to let me know when they are deleted that will say "Object Terminated". I have no errors when running it, but they do not get deleted when they fall past 560 on the Y-Axis.
I tried switching things around to see what would happen and I switched ">" to "<". This deleted
them immediately since they are lower than 560 on the y-axis, so why does it not work the other way round when they are higher than 560 on the y-axis? Is it because the get_position function does not get an updated value for the position? If so how do I get that?
extends RigidBody2D
func _ready():
var posY = get_position().y #gets y-axis position
randomize()
add_torque(rand_range(20,60))
if posY > 560:
queue_free()
print("Object Terminated") #checks that they are removed
The _ready() function is only called once when the node is added to the scene. You should put the check on the Y position in the _process() function which is called every frame.
Cedric's answer is correct (so I've up-voted it). Godot will only call the _ready function once (unless you tell Godot to call it again). And you would want to check your conditional periodically… Which you could do in _process which Godot will call once per graphics frame (unless you tell Godot to disable it).
However since we are talking about a RigidBody2D I would suggest _physics_process which runs once per physics frame (unless tell Godot to disable it). Or you can use _integrate_forces which will only run if the RigidBody2D moved (so it won't run on sleeping rigid bodies).

Calculate CV2 Homography by points and line

I have a list of points in the field (like upper_goal_point/ left_upper_outer_corner, etc.
I know their corresponding coordinates in destination image - so I can calculate the homography:
h, status = cv2.findHomography(pts_src, pts_dst)
I also have blue points in the upper corner line (look at image above), which I only know that their destination's y coordinates are 0 (because they are in the upper line), but I don't know where exactly they lay in that line.
Can I use those blue points in order to improve the homography?
P.S.
You can see that the upper corner line in the homography is not horizontal line, it's diagonal, which of course is not correct:
Actually it possible to use line correspondence in find homography.
https://www.researchgate.net/publication/220845575_Combining_Line_and_Point_Correspondences_for_Homography_Estimation
Several years ago we implement this approach in one project. During simplification all math we come up with simple trick. We transform every line a*x + b*y + c = 0 to point (a/c, b/c)
// *** Don't copy paste this code, read below! ***//
Point2f convertPointsToHomogeneousLine(Point2f p1, Point2f p2) {
Point3f p1h(p1.x, p1.y, 1);
Point3f p2h(p2.x, p2.y, 1);
Point3f lineHomo(p1h.y*p2h.z - p1h.z*p2h.y,
p1h.z*p2h.x - p1h.x*p2h.z,
p1h.x*p2h.y - p1h.y*p2h.x);
Point2f lineHomoNorm(lineHomo.x / lineHomo.z,
lineHomo.y / lineHomo.z);
return lineHomoNorm;
}
And pass this points inside. As I remember I also dig inside OpenCV implementation of findHomography and insert this lines somewhere inside to solve step. Inside OpenCV there some normalization applied to points before pass to solve step. So you need to skip this step for this kind of points.
We do not use it in production. User need to calibrate camera manually by providing lines and points on the image and in meter system. It has too complicated interface and bad stability. But in your case I think it can work better. If you will automatically find lines and correspondence.
P.S. Please note that in paper they use some normalization technique.
It will improve stability. We faced with stability problem, do not
solved it in our journey.

.translated function not working in Godot / best way to change position of bone

I'm working on a program in Godot using Gdscript, and I ran into a problem when trying to use the Transform.translated(Vector3) function. My code is supposed to move a bone to (0,0,0) by translating it by its current coordinates but with negative sign. Example: (1,2,3) would be translated by (-1,-2,-3) so it would end up at (0,0,0). For some reason when I do this, the end position of the bone is not (0,0,0), but some other coordinate. In the Godot documents, it says the .translated function is "relative to the transform's basis vectors", so maybe that's why? Also if there is a better way to change a bones position than using the Transform.translated(Vector3) function that would be helpful too. Thanks!
My Code:
bonePose = skel.get_bone_global_pose(bone)
var globalBonePose = skel.to_global(bonePose.origin)
translateVector = -globalBonePose
var newPose = bonePose.translated(translateVector)
skel.set_bone_pose(bone, newPose)
Code Output / Results:
bonePose (the original position of the bone) is around (-0.82,0.49,0.50)
translateVector (the amount the bone will be translated) is around (0.82,-0.49,-0.50)
newPose (the final position of the bone -- should be [0,0,0]) is around (0.82,-0.66,-0.46). Even when I call skel.to_global(newPose.origin) to see the global coordinates, it's (-0.76,0.44,0.42), which is not (0,0,0)
In Godot a Transform is composed of a basis (a Basis) and an origin (a Vector3). Where the origin handles the translation part of the transform, and the Basis the rest.
A Basis is the set of vectors that define the coordinate system. There is a vector that defines the x axis, another for the y axis, and another for the z axis. And this is the way Godot will encode rotation and scaling transformations.
When the documentation says "relative to the transform's basis vectors" it means the Basis will be applied to the vector you pass in. Thus, in your case, you are getting a translation on the local space of the bone. Which implies that if the bone is rotated or scaled (or something like that), that will affect the translation.
If you don't want to deal with rotation, scaling, et.al. I suggest you work with the origin of the Transform instead.
If you have a Transform and you want another that is otherwise equal but located at (0, 0, 0), you do this:
var new_transform = Transform(transform.basis, Vector.ZERO)
Or replace Vector.ZERO with whatever origin you want to give the new transform.
I also need to remind you that get_bone_global_pose and set_bone_pose do not operate on the same thing. On one hand set_bone_pose is relative to the parent bone, on the other get_bone_global_pose is relative to the Skeleton. Thus, I suggest you use set_bone_global_pose_override instead.
The final piece you need is the opposite of Spatial.to_global. Because setting the pose like as follows…
bonePose = skel.get_bone_global_pose(bone)
var newPose = Transform(bonePose.basis, Vector.ZERO)
skel.set_bone_global_pose_override(bone, newPose, 1.0)
… Would place it at the origin of the Skeleton.
Well, the opposite of Spatial.to_global is Spatial.to_local, and you would use it like this:
bonePose = skel.get_bone_global_pose(bone)
var newPose = Transform(bonePose.basis, skel.to_local(Vector.ZERO))
skel.set_bone_global_pose_override(bone, newPose, 1.0)
Here skel.to_local(Vector.ZERO) should give the origin of the world relative to the Skeleton. And given that set_bone_global_pose_override wants a Transform relative to the Skeleton, the result should be that the bone is placed at the origin of the world. With its rotation and scaling preserved.

Haskell Gloss : Making zoom, pan, and all that kind of effects for module Graphics.Gloss.Interface.Pure.Game

Recently I have been working on making a game with Haskell, and we have been using the library Gloss in order to complete the graphic part. To make a game with Gloss, as you probably know, you have to use Graphics.Gloss.Interface.Pure.Game (or IO game, that's not the main thing to focus here). My doubt is simple. As they say on their description of this module : "Pressing ESC will still abort the program, but you don't get automatic pan and zoom controls like with displayInWindow.". I have been trying to build those two effects but with no sucess. I made an accumulator in my state, called v, that gets the value of 1 when 'reactEvent (EventKey (MouseButton WheelUp) Down _ _) ((px,py),p,mapas,i,players,b,c,d,v) = ((px,py),p,mapas,i,players,b,c,d,1)' and then the function that makes the picture appear would turn it back to 0 after applying the effect needed, creating a cicle. What's the mistake in my logic?
Edit : Added the prints, that's what I am trying to get to work. Also, if anyone has a clue on how to make different camera angles, I would also appreciate some help.
https://imgur.com/3PAqO2x
https://imgur.com/jk93lzQ

What do the 'M', 'c' and 'z' mean in SVG paths?

http://paperjs.org/examples/
I'm trying to create a custom path with Chain, and I see that Tadpoles has a predefined heart-shaped path, so I'm trying to copy it but I don't understand a few parts of it.
var heartPath = new Path('M514.69629,624.70313c-7.10205,-27.02441 -17.2373,-52.39453 -30.40576,-76.10059c-13.17383,-23.70703 -38.65137,-60.52246 -76.44434,-110.45801c-27.71631,-36.64355 -44.78174,-59.89355 -51.19189,-69.74414c-10.5376,-16.02979 -18.15527,-30.74951 -22.84717,-44.14893c-4.69727,-13.39893 -7.04297,-26.97021 -7.04297,-40.71289c0,-25.42432 8.47119,-46.72559 25.42383,-63.90381c16.94775,-17.17871 37.90527,-25.76758 62.87354,-25.76758c25.19287,0 47.06885,8.93262 65.62158,26.79834c13.96826,13.28662 25.30615,33.10059 34.01318,59.4375c7.55859,-25.88037 18.20898,-45.57666 31.95215,-59.09424c19.00879,-18.32178 40.99707,-27.48535 65.96484,-27.48535c24.7373,0 45.69531,8.53564 62.87305,25.5957c17.17871,17.06592 25.76855,37.39551 25.76855,60.98389c0,20.61377 -5.04102,42.08691 -15.11719,64.41895c-10.08203,22.33203 -29.54687,51.59521 -58.40723,87.78271c-37.56738,47.41211 -64.93457,86.35352 -82.11328,116.8125c-13.51758,24.0498 -23.82422,49.24902 -30.9209,75.58594z');
I don't understand what the M at the start of the path means, or the c in some of the values or z at the end of the path. I tried to find info about it in their docs or Google it but I can't find what I want because single letters make searching tough.
I tried to remove the M at the start and the Tadpoles stopped moving, so I assume M potentially means 'moving'? Removing the c alters the shape of the heart, but removing the z doesn't seem to change anything.
M: Move to
The command "Move To" or M, which was described above. It takes two parameters, a coordinate ' x ' and coordinate ' y ' to move to. If your cursor already was somewhere on the page, no line is drawn to connect the two places. The "Move To" command appears at the beginning of paths to specify where the drawing should start
z: Close Path
This command draws a straight line from the current position back to the first point of the path. It is often placed at the end of a path node, although not always. There is no difference between the uppercase and lowercase command.
c: Bezier Curves
The cubic curve, C, is the slightly more complex curve. Cubic Beziers take in two control points for each point. Therefore, to create a cubic Bezier, you need to specify three sets of coordinates.
source: https://developer.mozilla.org/en/docs/Web/SVG/Tutorial/Paths
-EDIT-
You can visit https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d for a full reference to all the possible commands and their usage.
The constructor you are invoking is this:
Path(, pathData)
Where pathData is described as:
the SVG path-data that describes the geometry of this path
The documentation you should read is the one of SVG.
As #GerardoFurtado mentioned in the comments, here is a read that could be of interest for you.

Resources