Quantcast
Channel: All Revit API Forum posts
Viewing all 67020 articles
Browse latest View live

Re: Family Instance Point Reference

$
0
0

Is this code related to an adaptive component family, this is only template with point references as far as I know?

 

In general for most family instances Location (Element.Location) is Inherited by LocationPoint and LocationCurve so if you try to cast to one and get null then it is likely the other.

 

Some family instances don't have a location, see recent thread below:

 

https://forums.autodesk.com/t5/revit-api-forum/why-is-element-location-null-for-perfectly-valid-familyinstance/m-p/8076733/highlight/true#M31755


Re: Batch Replace family text file in multiple rfa files

$
0
0

I don't think journals are the correct approach. The whole journal system I believe was created so you could send your file to the people who would then run your Revit session to diagnose a problem you had. If you manually go through the process for one file you'll probably find (after you've cleaned up the jumble) how viable that would be via copy and paste.

 

Seems you would be better off doing via the API but there are complications such as ensuring you don't try and close the last document. Dynamo is usually per project so I don't know how viable it is to switch between projects during a run but since automation often requires this kind of behaviour such a limitation may have been overcome by now.

Re: Programming Plugins

Re: Ribbon Panel items are disabled when 3d view is activated.

$
0
0

Hard for anyone to say if you share no code indicating what you have done to create the items on the ribbon.

 

e.g. have you implemented IExternalCommandAvailability at all if so how?

Re: FilteredElementCollector get all category and sub category

$
0
0

Please explain what your question is.

 

Yes, you can get elements for all categories.

 

Yes, you can get elements for individual categories.

 

Yes, you can get elements for a whole set of categories, e.g.:

 

http://thebuildingcoder.typepad.com/blog/2010/06/retrieve-mep-elements-and-connectors.html

http://thebuildingcoder.typepad.com/blog/2010/07/retrieve-structural-elements.html

 

Yes, you can retrieve all model elements:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9

 

You have not specified your question.

 

I hope this helps anyway.

 

Cheers,

 

Jeremy

 

Re: RevitUIDocument.ActiveView Setter behaves not like Changing view with UI

$
0
0

Dear Thomas,

 

Thank you for your interesting query.

 

I cannot say much about this surprising behaviour off-hand.

 

A reproducible case would be interesting to share with the development team:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

However, regardless what they do or do not do, that would cost some time.

 

Here is a suggestion that you could and might want to try out right away to activate a view in a manner that is much more similar to the manual view activation, using the 'zoom to element' functionality:

 

http://thebuildingcoder.typepad.com/blog/2018/03/switch-view-or-document-by-showing-elements.html

 

I hope this helps.

 

Cheers,

 

Jeremy

 

Re: Dictionary for Revit and AutoCAD Terms for Localisation

Problem with parameter value change

$
0
0

I am using Revit 2015. I wanted to create a simple macro which would change the value of 3 parameters in every family type. Unfortunately it is not working as it should, and instead only changes the value of the first parameter on the list. The while loop of the code iterates through all the types in the set, but changes only the values of the first one.

 

I am quite new to the Revit API, so I ask for your kind help in resolving my problem or guiding me to possible solution. Thank you very much in advance.

 

 

		public void ParameterChange()
		{

			Document doc = this.Document;
			using(Transaction tr = new Transaction (doc, "RenameParameter")){
			tr.Start();
			string types = "Types:";
			FamilyManager familyManager = doc.FamilyManager;
			FamilyTypeSet familyTypes = familyManager.Types;
			FamilyTypeSetIterator familyTypesItor = familyTypes.ForwardIterator();
			familyTypesItor.Reset();
			
				while(familyTypesItor.MoveNext()){
				FamilyType familyType = familyTypesItor.Current as FamilyType;
				FamilyParameter par1 = familyManager.get_Parameter("Param1");
				FamilyParameter par2 = familyManager.get_Parameter("Param2");
				FamilyParameter par3 = familyManager.get_Parameter("Param3");
				familyManager.Set(par1, "value1");
				familyManager.Set(par2, "value2");
				familyManager.Set(par3, 10);
				types += "\n" + familyType.Name;
				}
				tr.Commit();
			TaskDialog.Show("Revit",types);
			}
		}

 


Re: Get worksets from detached model

$
0
0

Thanks!


 wrote:
 Dim WF As New WorksetKindFilter(WorksetKind.UserWorkset)
 Dim FWC As New FilteredWorksetCollector(Document)

 FWC.WherePasses(WF).ToWorksets()
 'or
 FWC.WherePasses(WF).ToWorksetIds()

Perhaps these objects above?

 

Note that when you detach a model there is an option for discarding worksets. A detached model only really exists between the time you detach and when you first save it.


 

Surprising results from Face.Intersect(face) method

$
0
0

This has been mentioned in this post from 2016 but maybe it's worth bringing up again as 2018 hasn't resolved the issue yet.

 

As far as I can tell, the Face.Intersect(face) method always returns FaceIntersectionFaceResult.Intersecting - or I am not implementing it correctly. When I run the code below in a view with a single wall and single floor, each face to face test returns an intersection. Can someone please verify (maybe 2019)?

 

intersects.PNG

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

var list = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document, commandData.View.Id).WhereElementIsNotElementType().Where(e => e is Wall || e is Floor);


foreach (var f1 in list.First().get_Geometry(new Options()).OfType<Solid>().First().Faces.OfType<Face>())
{
foreach (var f2 in list.Last().get_Geometry(new Options()).OfType<Solid>().First().Faces.OfType<Face>())
{
if (f1.Intersect(f2) == FaceIntersectionFaceResult.Intersecting)
{

if (System.Windows.Forms.MessageBox.Show("Intersects", "Continue", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Cancel) return Result.Succeeded;
}
}
}

return Result.Succeeded;
}

Re: Family Instance Point Reference

$
0
0

, it's not an adaptative component family... What I'm trying to do is get some point reference to transform into a Reference so I can create a dimension using it. The families with I intend to do this usually are Plumbing Fixtures, Pipe Accessories or Pipe Fittings.

Until now I didn't have problem to get the Location Point, but I thank you to let me know that this can be a problem in the future.

 

I was using the Revit Lookup (from The Building Coder) to snoop this families and below are the diference:

1.PNGWithour Point Reference

 

2.PNGWith Point Reference

 

 

 

Exceptions in Document.Import (with parameter ImageImportOptions)

$
0
0

Hello,

we use many calls to Document.Import to display image tiles placed in the manner of a grid in a floor view.

This is the API Method we use:

 

C#
publicboolImport(stringfile,ImageImportOptionsoptions,Viewview,outElementelement
)

 

Most of the time it works very well.

However, recently we received a customer report about this method raising an exception.
Even worse, the exception message does not help to understand the cause of the problem:

Error message
 Un composant externe a levé une exception.

Stack trace
 à FileImportExport.importImage(ADocument* , ImageImportOptions* , ElementId* )
 à Autodesk.Revit.DB.Document.Import(String file, ImageImportOptions options, View view, Element& element)

Sorry about the french message, I believe in english the exception message would read like "an external component has raised an exception".


Did anyone experience similar problems? Are there any ideas about the cause or why the exception message is so vaguely phrased? Are there any ideas for a workaround or how we could avoid this?

 

Thanks,

Armin

 

 

 

 

 

Re: Dockable Panes Duplicating in 2019

$
0
0

Any updates on this?  I have other customers now reporting it...

Render Material Texture Image

$
0
0

Do we have access to a material's texture image thru Revit's API, and/or Dynamo?

Auto insert control point of electrical circuit?

$
0
0

Hi everyone,
This is a electrical circuit. We can insert control point in circuit for change the way circuit run. Then we can auto insert control point at floor or concrete ceiling or any point?
Thanks all.insert control point.PNG


Re: Filled Region (Hatch Pattern) Area Value

$
0
0

oke, that looks intresting. but what package are you usiing for this script? 


 wrote:

You can use Dynamo to do this.

 Refer attachment.

 


 

Re: Load as Group Revit API

$
0
0

Hello,I am working on copying a group from one document to another after I read your advice. However, the code always fails. Would you please check my code and give some advice. Thanks a lot! Following is my code:

 

 

using System;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace HelloWorld
{
[Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
{
TaskDialog.Show("Start", "Hello World!");

Application app = revit.Application.Application;
UIDocument uiDoc = revit.Application.ActiveUIDocument;
Document doc = uiDoc.Document;

using (Transaction trans = new Transaction(doc))
{
if (trans.Start("放置组1") == TransactionStatus.Started)
{
string address1 = @"C:\Users\machine\Desktop\组 1.rvt";
Document openDoc = app.OpenDocumentFile(address1);
FilteredElementCollector collector = new FilteredElementCollector(openDoc).OfClass(typeof(GroupType));
var query = from element in collector where element.Name == "组 1" select element;
List<Element> groups = query.ToList();
ElementId groupId = groups[0].Id;
ICollection<ElementId> copyIds = new Collection<ElementId>();
copyIds.Add(groupId);
ElementId copied = ElementTransformUtils.CopyElements(openDoc, copyIds, doc, Transform.Identity, new CopyPasteOptions()).First();

XYZ location = uiDoc.Selection.PickPoint("请指定插入房间的位置");
FilteredElementCollector collector1 = new FilteredElementCollector(doc).OfClass((typeof(GroupType)));
var groupTypes1 = from element in collector1 where element.Name == "组 1" select element;
GroupType groupType = groupTypes1.First() as GroupType;
Group groupCreated = doc.Create.PlaceGroup(location, groupType);

if (TransactionStatus.Committed == trans.Commit())
{
if (groupCreated != null)
{
TaskDialog.Show("创建成功", "组 1已包含在模型中");
}
else
{
TaskDialog.Show("创建失败", "没有创建组 1");
}
}
else
{
trans.RollBack();
}
}
}

return Result.Succeeded;
}
}
}

 

20180621152832.png

Print to PDF issue for printmanager Revit API

$
0
0

When I tried to use printManager API for Revit using C# for the batch process,

 

It is asking "Save as" dialog every time and expecting user has to click Ok. Can anyone help me to stop this dialog?

 

 

Re: How to transform three-dimensional coordinates into two-dimensional coordina

$
0
0

Thanks for your help,i've solved the problem.Heart

Re: Get the scan zone of PointCloud

Viewing all 67020 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>