Wall Dimensioning - revit-api

I would like to set the gap from the element to some value so that the dimension would be clearly visible. Please find below the screen shot.
Currently it's looking like this.
But I would like to achieve like below.

You are actually in control of the line when you create the dimension. Take a line from Revit then transform it and offset it perpendicular to the line you're interested in: (Given a dbView and a reference array and a curve)
//create your line along the element you want to dimension
Line line = Line.CreateBound(locCurve.Curve.GetEndPoint(0), locCurve.Curve.GetEndPoint(1));
//Compute the perpendicular of that line (I took advantage of the fact that I was working in plan:
XYZ perpendicular = line.ComputeDerivatives(0.5, true).BasisX.CrossProduct(new XYZ(0, 0, 1));
//transform the line to the new offset location:
Line offsetline = line.CreateTransformed(Transform.CreateTranslation(perpendicular.Normalize())) as Line;
//Create the dimension.
revitDoc.Create.NewDimension(dbView, offsetline, aDimensionRefArray);

Related

vtkProperty SetLineStipplePattern working but SetLineWidth not..?

I have created a vtkLineSource that is passed to vtkPolyDataMapper, passed to vtkActor.
actor->GetProperty()->SetLineStipplePattern(0xf0f0);
works like a charm. However
actor->GetProperty()->SetLineWidth(5.0);
does nothing.
Both methods are marked "This is only implemented for OpenGL."
Here's the snippet:
vtkSmartPointer<vtkLineSource> line1 = vtkSmartPointer<vtkLineSource>::New();
line1->SetPoint1(posvel1.x, posvel1.y, posvel1.z);
line1->SetPoint2(posvel2.x, posvel2.y, posvel2.z);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(line1->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetLineWidth(2.0); // TODO: Has no effect.
actor->GetProperty()->SetColor(1, 1, 1);
actor->GetProperty()->SetOpacity(0.5);
actor->GetProperty()->SetLineStipplePattern(0xf0f0);
actor->GetProperty()->SetLineStippleRepeatFactor(1);
// Further up, add actor to vtkAssembly
Line shows and has stipple pattern, but width is unaffected by whatever value I pass to SetLineWidth.
Edit: I already had a comment in my code. "Replace with vtkPoints polygon drawing instead of LineSource needed probably..." Tested this: Does not solve the issue, stipple pattern is there, line width does not work.
== Edit ==
What alternatives are there to draw a 2D dashed/dotted line in a 3D scene with vtk?

Plot points playing games when I try to size by a value count in bokeh

I'm trying to get the plot points in a scatter graph to size according to the frequency of values in a column of data. The data is coming from a questionnaire.
My questions are: What am I doing wrong, and what can I do to fix it?
I can push out a simple plot with x and y values coming from 2 columns of data. The X axis represents a level (1-100), and the Y axis represents a choice users can make for each level (1-4). For this plot I want to track how many people choose 1-4 on each level - so I need to capture that 1-4 has been selected, then indicate how many times.
Simple plot works fine, though those points have multiple occurrences.
Here's the code for that:
# Set up the graph
WT_Number = data.wt # This is the X axis
CFG_Number = data.cfg # This is the Y axis
wt_cfg_plot = figure(plot_width=1000, plot_height=400,
title="Control Form Groups chosen by WT unit")
# Set up the plot points, including the Hover Tool
cr = wt_cfg_plot.scatter(WT_Number, CFG_Number, size=7,
fill_color="blue",
line_color=None, alpha=0.7, hover_fill_color="firebrick",
hover_line_color=None, hover_alpha=1)
Problem: I then added a value count and set it as the size, to get the plot points to adjust according to the value frequency. But now it pumps out this chart and throws an error:
Plot points are reacting to the code, but now they're doing their own thing.
I added a variable for the value counts (cfg_freq), and used that as the size:
cfg_freq = data['cfg'].value_counts()*4
cr = wt_cfg_plot.scatter(WT_Number, CFG_Number, size=cfg_freq, fill_color="blue",
line_color=None, alpha=0.7, hover_fill_color="firebrick",
hover_line_color=None, hover_alpha=1)
Here's the the last part of the error being thrown:
File "/Applications/anaconda/lib/python3.5/site-packages/bokeh/core/properties.py", line 722, in setattr
(name, self.class.name, text, nice_join(matches)))
AttributeError: unexpected attribute 'size' to Chart, possible attributes are above, background_fill_alpha, background_fill_color, below, border_fill_alpha, border_fill_color, disabled, extra_x_ranges, extra_y_ranges, h_symmetry, height, hidpi, left, legend, lod_factor, lod_interval, lod_threshold, lod_timeout, logo, min_border, min_border_bottom, min_border_left, min_border_right, min_border_top, name, outline_line_alpha, outline_line_cap, outline_line_color, outline_line_dash, outline_line_dash_offset, outline_line_join, outline_line_width, plot_height, plot_width, renderers, responsive, right, tags, title, title_standoff, title_text_align, title_text_alpha, title_text_baseline, title_text_color, title_text_font, title_text_font_size, title_text_font_style, tool_events, toolbar_location, tools, v_symmetry, webgl, width, x_mapper_type, x_range, xgrid, xlabel, xscale, y_mapper_type, y_range, ygrid, ylabel or yscale

KMZ - Line with angulation and direction

Good afternoon.
Sorry for my bad english.
I would like to draw fixed lines in the map that would set the starting point with the coordinates, an angle of direction and dimension to the line without setting the end point coordinates.
Example: A line that would start in a given geographical coordinates -12.3456789, -49.3456789 has angle of 123 ° clockwise and has XXkm dimension.
It is possible to add lines like this in KMZ Google Earth?
Please to post it with some example code or suggestions.
KML (or KMZ) only can represent a line as a collection of points with at a minimum a start and end point.
https://developers.google.com/kml/documentation/kmlreference#linestring
You could calculate an end point from a starting point, angle of direction (or heading), and distance then represent display it in Google Earth using KML.
For example in the OpenSextant geodesy java library you can create a Geodetic2DArc and calculate the endpoint in 3 lines of java code like this:
Geodetic2DPoint start = new Geodetic2DPoint(new Longitude(-49.3456789, Angle.DEGREES),
new Latitude(-12.3456789, Angle.DEGREES));
Geodetic2DArc arc = new Geodetic2DArc(start, 5000.0, new Angle(123, Angle.DEGREES));
Geodetic2DPoint endPt = arc.getPoint2();
The distance is in meters so if you want a long line segment then you need a larger distance.
Then with the associated Giscore library you could export the line into KML directly with few more lines of java code:
KmlOutputStream kos = new KmlOutputStream(new FileOutputStream("out.kml"));
Feature f = new Feature();
f.setName("line");
List<Point> pts = new ArrayList<Point>(2);
pts.add(new Point(start));
pts.add(new Point(endPt));
f.setGeometry(new Line(pts));
kos.write(f);
kos.close();

Bumpy jigsaw type data into curve data

I have a problem I solved in Excel but I am completely stuck in Matlab.
A weight measuring how much liquid I pump is refilled when its almost empty. Here is a picture
Now I want to see it in one motion, not like a jigsaw. Here is my solution, doing it manually in Excel:
Now to Matlab where this should be done automatically: I know how to index the row before and after I have the bumps, but I'm kind of stuck now. I do d=diff(x) ok and now I can replace the high peaks when the bumps occur (i=d(:,1)>0) with 0 so it never happened. And how do I translate it back? Somehow "undiff(x)"? im completely lost.
Here's an extract of my x:
2533,30
3540,00
3484,90
3430,00
3375,00
3320,20
3265,60
3210,60
3155,80
3101,20
3046,50
2991,70
2937,00
2882,50
2828,10
2773,80
2719,30
2664,90
2610,50
2556,10
2501,60
3508,00
3454,00
3399,70
3352,10
Like this?
temp = [0; diff(x)];
temp(temp < 0) = 0;
y = x - cumsum(temp);
y(temp > 0) = interp1(y, find(temp > 0) + 0.5);
plot(y);
hen using the default plot() function, matlab will automatically draw a line plot and connect each point in the data you are plotting.
Instead it seems like you just need to plot the points individually and unconnected. So if you are currently doing something like plot(x) or area(x) instead try plot(x,'o'). This will cause Matlab to plot the points individually without connecting them as lines.
If you'd like to change the marker type used to plot each point, use doc linespec to get more info.

VTK: Put Label/Text near points in the 3d plot

I have written a code which plots multiple 3d points as spheres. I want to add some text near each sphere in 3D to mention some info about each point. But I have vtkPoints to store points positions which doesn't have GetOutputPort which I need in labelMApper (and also used glyph3d to make spheres)
vtkSmartPointer<vtkLabeledDataMapper> labelMapper = vtkSmartPointer<vtkLabeledDataMapper>::New();
labelMapper->SetInputConnection( vtkpoints->GetOutputPort() ); // No GetOutputPort()
vtkSmartPointer<vtkActor2D> labelActor = vtkSmartPointer<vtkActor2D>::New();
labelActor->SetMapper(labelMapper);
renderer->AddActor(labelActor);
You should construct a vtkPolyData from the points and set it as Input to the label mapper.
Something like this:
vtkNew<vtkPolyData> labelPolyData;
labelPolyData->SetPoints(labelPoints);
labelMapper->SetInput(labelPolyData); // Note: If you're using VTK from master (6.x), this is SetInputData(...)
renderer->AddActor2D(labelActor);

Resources