we want to draw dimensions between sleeve (specialty equipment) and Grid lines .
but when we apply dimensions revit throw the error message "Remove References - The references of highlighted dimension are no longer parallel"
XYZ sleeve_xyz = null;
Element elm = doc.GetElement(Sleeve_id.Id);
FamilyInstance fi = elm as FamilyInstance;
Autodesk.Revit.DB.Location position = elm.Location;
Autodesk.Revit.DB.LocationPoint positionPoint = position as Autodesk.Revit.DB.LocationPoint;
sleeve_xyz = positionPoint.Point;
sleeve_xyz = new XYZ(sleeve_xyz.X, sleeve_xyz.Y, 0);
Reference sleeve_ref = GetSleeveReference(fi, SpecialReferenceType.CenterLR);
Grid first_grid2 = doc.GetElement(First_Grid_elemID) as Grid;
Reference gridRef = null;
Options opt = new Options();
opt.ComputeReferences = true;
opt.IncludeNonVisibleObjects = true;
opt.View = doc.ActiveView;
foreach (GeometryObject obj in first_grid2.get_Geometry(opt))
{
if (obj is Autodesk.Revit.DB.Line)
{
Autodesk.Revit.DB.Line line = obj as Autodesk.Revit.DB.Line;
gridRef = line.Reference;
}
}
XYZ gr_point2 = new XYZ(grid_intersection_point.X, sleeve_xyz.Y, 0.000000000);
Autodesk.Revit.DB.Line line5 = null;
line5 = Autodesk.Revit.DB.Line.CreateBound(gr_point2, sleeve_xyz);
ReferenceArray refArray = new ReferenceArray();
refArray.Append(sleeve_ref);
refArray.Append(gridRef);
Dimension dim = doc.Create.NewDimension(doc.ActiveView, line5, refArray);
Error
Create a dimension that works manually through the user interface first, then use RevitLookup to analyse its properties and find out what exact references it has picked up. In general, if a feature is not available in the Revit product manually through the user interface, then the Revit API will not provide it either.
Related
I'm currently working on modifying a Tree View control (Telerik MVC Extensions) for a customer request. Their request is a simple one: if an item within the tree has an Attachment, add a paperclip beside the node to identify it.
I have so far been able to do so but, found a small hiccup with this. I can add the image to certain nodes that have an Attachment, however, all nodes that don't should have no image (by that, I mean they should appear normal within the tree). Instead though, I find that the tree places a blank the size of the paperclip image.
Is there a way to dynamically turn off this blank (aka not add an Image Url if unnecessary)? Below is my code where I'm executing this process (is done on the expansion method of the tree due that only the bottom level shows the Attachments).
Navigation Controller
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GetNextTreeViewLevel(TreeViewItem node)
{
...
//If bottom layer, then execute the following
var data = _TreeRepo.GetProcessesByParcel(int.Parse(values[1]), cntTreeList);
nodes = from item in data
select new TreeViewItem
{
Text = item.strProcess,
Value = "PR" + "," + item.cntProcess.ToString(),
LoadOnDemand = false,
Enabled = true,
Selected = SelectedSearchResult.ToString().Length > 0
&& SelectedSearchResult.ToString().Split('~').Length > 3
&& decimal.Parse(SelectedSearchResult.ToString()
.Split('~')
.Last()
.Substring(2)) == item.cntProcess
ImageUrl = item.ysnHasAttachment.HasValue && item.ysnHasAttachment.Value == 1
? #"/Content/NewImages/attachment.png"
: string.Empty
};
return new JsonResult { Data = nodes };
}
Screen shots of what it looks like without/with code for Image Url:
I at long last came up with a solution to this issue. The problem was how I was getting my data added to the nodes. The original logic was doing a Linq query after fetching the data to get an IEnumerable object.
Because of that, every node was trying to add an image (even if there was none). Hence the weird looking space. Below is how I reworked this logic to correctly get my data.
var processNodes = new List<TreeViewItem>();
var data = _TreeRepo.GetProcessesByParcel(int.Parse(values[1]), cntTreeList);
foreach (var item in data)
{
#region Process has at least one Attachment
if (item.ysnHasAttachment.HasValue && item.ysnHasAttachment.Value == 1)
processNodes.Add(new TreeViewItem
{
Text = item.strProcess,
Value = "PR" + "," + item.cntProcess.ToString(),
LoadOnDemand = false,
Enabled = true,
Selected = SelectedSearchResult.ToString().Length > 0
&& SelectedSearchResult.ToString().Split('~').Length > 3
&& decimal.Parse(SelectedSearchResult.ToString()
.Split('~')
.Last()
.Substring(2)) == item.cntProcess,
ImageUrl = "/Content/NewImages/smallAttachment.png"
});
#endregion
#region Process has no Attachments
else
processNodes.Add(new TreeViewItem
{
Text = item.strProcess,
Value = "PR" + "," + item.cntProcess.ToString(),
LoadOnDemand = false,
Enabled = true,
Selected = SelectedSearchResult.ToString().Length > 0
&& SelectedSearchResult.ToString().Split('~').Length > 3
&& decimal.Parse(SelectedSearchResult.ToString()
.Split('~')
.Last()
.Substring(2)) == item.cntProcess
}
#endregion
}
nodes = processNodes;
At this point, you can now return the nodes. Those that should have had an Attachment icon will, and those that shouldn't won't. Funny how 4 months later, you can come up with something off the cuff.
I've been able to create a PivotTable separate from the raw/source data, but now I want to combine the two, with the PivotTable allowing filtering of the spreadsheet data by providing filters on the column heading row, like this:
I tried this code:
private void AddPivotTable()
{
// The commented-out code below placess the PivotTable below the actual data, separate from it:
//string colAlphaRowNum = string.Format("A{0}", locationWorksheet.Dimension.End.Row+5);
// Here I am attempting to incorporate the PivotTable within the data itself (one row above it, actually)
string colAlphaRowNum = "A5";
ExcelAddressBase eab = locationWorksheet.Cells[colAlphaRowNum];
ExcelRangeBase erb = locationWorksheet.Cells[6, 1, locationWorksheet.Dimension.End.Row, locationWorksheet.Dimension.End.Column];
var pt = locationWorksheet.PivotTables.Add(eab, erb, "Pivotous");
pt.RowFields.Add(pt.Fields[0]);
pt.RowFields.Add(pt.Fields[1]);
pt.RowFields.Add(pt.Fields[2]);
pt.RowFields.Add(pt.Fields[3]);
pt.RowFields.Add(pt.Fields[4]);
pt.RowFields.Add(pt.Fields[5]);
pt.MultipleFieldFilters = true;
pt.RowGrandTotals = true;
pt.ColumGrandTotals = true;
pt.Compact = true;
pt.CompactData = true;
pt.GridDropZones = false;
pt.Outline = false;
pt.OutlineData = false;
pt.ShowError = true;
pt.ErrorCaption = "[error]";
pt.ShowHeaders = true;
pt.UseAutoFormatting = true;
pt.ApplyWidthHeightFormats = true;
pt.ShowDrill = true;
pt.DataOnRows = false;
pt.FirstHeaderRow = 1; // first row has headers
pt.FirstDataCol = 1; // first col of data
pt.FirstDataRow = 2; // first row of data
pt.TableStyle = TableStyles.Medium6; // There is a "custom" and several Dark, Light, and Medium options
}
...but this does not work. I get this dialog when I open the generated sheet:
If I select "Yes" this is what I see:
If I select "No", I see this:
...which is promising, but if I then drop down the "Row Labels", deselect the "(Select All)" and then select the first item ("Stern"), I see this:
This is not what I want; in the model (hand-crafted) sheet, deselecting "Select All" and then selecting a single item filters the data to just include that data ("Foster" in this case), like so:
...rather than replacing the first part of the data with a restricted PivotTable.
What do I need to do to make this work as intended?
Perhaps my nomenclature was faulty, because I think what I really want is not necessarily a PivotTable, but the ability to filter.
And, although attempting to do it this way, which seems logical and is even theoretically correct:
using (var shortNameCell = locationWorksheet.Cells[rowToPop, SHORTNAME_BYDCBYLOC_COL])
{
shortNameCell.Value = "Short Name";
shortNameCell.Style.WrapText = false;
shortNameCell.Style.Font.Size = 12;
shortNameCell.AutoFilter = true;
}
using (var companyNameCell = locationWorksheet.Cells[rowToPop, COMPANYNAME_BYDCBYLOC_COL])
{
. . .
companyNameCell.AutoFilter = true;
}
using (var reasonDescCell = locationWorksheet.Cells[rowToPop, REASONDESC_BYDCBYLOC_COL])
{
. . .
reasonDescCell.AutoFilter = true;
}
using (var transTypeCell = locationWorksheet.Cells[rowToPop, TRANSTYPE_BYDCBYLOC_COL])
{
. . .
transTypeCell.AutoFilter = true;
}
...results in only the final column thus appointed to sport filtration abilities, the following works for all four:
locationWorksheet.Cells["A6:D6"].AutoFilter = true;
Using the last, I get the following:
UPDATE
It was a Pivot Table that I needed after all, and what I did to get a start on how to accomplish what I need is shown in my auto-answer here.
I am working with Aspose slides to generate PPT in my application, I ran into a situation where I need to insert HTML text into Table Cell, I verified all blogs no one given answer to me. If any body know here please let me know. Thanks In advance.
You can use the TextFrame's paragraph associated with each cell to insert HTML using Aspose.Slides for .NET. Check the following code:
//Instantiate Presentation class that represents PPTX file
using (Presentation pres = new Presentation())
{
//Access first slide
ISlide sld = pres.Slides[0];
//Define columns with widths and rows with heights
double[] dblCols = { 250, 250};
double[] dblRows = { 150, 130, 130 };
//Add table shape to slide
ITable tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows);
//Set border format for each cell
foreach (IRow row in tbl.Rows)
foreach (ICell cell in row)
{
cell.BorderTop.FillFormat.FillType = FillType.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderTop.Width = 5;
cell.BorderBottom.FillFormat.FillType = FillType.Solid;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderBottom.Width = 5;
cell.BorderLeft.FillFormat.FillType = FillType.Solid;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderLeft.Width = 5;
cell.BorderRight.FillFormat.FillType = FillType.Solid;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderRight.Width = 5;
}
//Adding html text in text frame
tbl[0, 0].TextFrame.Paragraphs.AddFromHtml(#"<html><body><p><b>This text is bold</b></p>
<p><i>This text is italic</i></p><p>This is<sub> subscript</sub> and <sup>superscript</sup></p>
</body></html>");
//Write PPTX to Disk
pres.Save("d:\\data\\table_html.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}
P.S. I am working as social media developer at Aspose.
Here is what I am doing basically.
var Player1:Object = {age:Number,playerName:String};//etc... I need each Player to have the same set of properties.
var Player2:Object = {age:Number,playerName:String};
var Player3:Object = {age:Number,playerName:String};
var Player3:Object = {age:Number,playerName:String};
Now, I have a LOT more properties in each object, and I am creating them all dynamically through for loops and arrays. So each object will have a random name, age, etc...
I hate that I have to write the same line of code over and over, the only thing changing is the number at the end of the word Player.
What I want is...
createPlayers(4);
function createPlayers(a){
for(var i=1;i<a;i++){
var thisPlayer = "Player" + i;
thisPlayer:Object = {age:Number,playerName:String};
}
Now, of course I cannot reference them because the var thisPlayer was created in the function.
I also tried:
Players:Object = {age:Number,playerName:String};
Player1:Players = new Players //OR
Player1:Object = new Players //ETC...
I am missing something here.
I want to assign a "Player1" Object to a "P1" var so the btnP1 can call upon it.
case btnP1:txt_name.text = P1.playerName;
case btnP2:txt_name.text = P2.playerName; //etc...
I have a spinner I'm populating from the database. I want to choose which item from the list is selected by default. I need to find out what item in the list (CursorAdapter) has the value "Default Away" and set that to the selected value.
Spinner away_team_spinner = (Spinner)findViewById(R.id.away_team_spinner);
DatabaseHelper db = new DatabaseHelper(this);
Cursor team_list = db.getTeams(p_game_level);
startManagingCursor(team_list);
String[] team_name = new String[]{colTeamName};
int[] to = new int[]{android.R.id.text1};
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, team_list, team_name, to );
adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
away_team_spinner.setAdapter(adapter);
//// HERE IS WHERE MY ERRORS START ////
Log.i("NEW_GAME","Before set arrayadapter");
CursorAdapter adapter_choose = (CursorAdapter)away_team_spinner.getAdapter();
Log.i("NEW_GAME","Before set setSelection");
away_team_spinner.setSelection(adapter_choose.getPosition("Default Away"));
This is the "solution" I found by searching on this web site. However, I cannot use "getPosition" with CursorAdapter object. I tried ArrayAdapter, but then the line after "Before set arrayadapter" comment errors with "android.widget.SimpleCursorAdapter cannot be cast to android.widget.ArrayAdapter". What am I doing wrong? Thanks.
have you thought about running a for loop until you find the position then set the adapter position that way? ill draft up some code then test it, i'm doing something similar
and well this just did the trick, enjoy!
int cpos = 0;
for(int i = 0; i < simpleCursorAdapter.getCount(); i++){
cursor.moveToPosition(i);
String temp = cursor.getString((your column index, an int));
if ( temp.contentEquals(yourString)){
Log.d("TAG", "Found match");
cpos = i;
break;
}
}
spinner.setSelection(cpos);