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

Is a model Workshared without opening the file

$
0
0

Can I tell if a model is Workshared without opening the file?

Also, can I tell the models version without opening the file?

Also, can I tell the local file folder without opening the file>

Kind Regards

David

 


Unloading worksets from linked models

$
0
0

Hi,

 

I am writing a routine that would unload 3 worksets from our linked models. Based on everything I have found online, I believe I written this correctly. However everytime i run this routine nothing appears to happen. The only thing I can think of that would be limiting me is how i filter down to just those names that is the issue. I have never tried to write anything that is accessing inside a linked model.

 

public void unloadlinkwrkst(UIApplication uiapp, Document doc)
        {
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;

            try
            {

                List<Element> lstRvtLinkType = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkType)).ToList();

                foreach (Document _linkdoc in app.Documents)
                {
                    if (!_linkdoc.IsLinked)
                        continue;
                    RevitLinkType _RvtLinkType = null;

                    foreach (Element elmnt in lstRvtLinkType)
                    {
                        _RvtLinkType = elmnt as RevitLinkType;
                        if (_RvtLinkType.Name != _linkdoc.Title)
                            continue;
                        else
                            break;
                    }

                    List<WorksetId> lstWkSet_Close = new List<WorksetId>();

                    WorksetConfiguration wk = new WorksetConfiguration();
                    ModelPath _modelpath = _linkdoc.GetWorksharingCentralModelPath();
                    WorksetTable _worksetTable = _linkdoc.GetWorksetTable();
                    IList<WorksetPreview> lstPreview = WorksharingUtils.GetUserWorksetInfo(_modelpath);

                    foreach (WorksetPreview item in lstPreview)
                    {
                        Workset wkset = _worksetTable.GetWorkset(item.Id);
                        if (!wkset.IsOpen)
                        {
                            if ((item.Name.CompareTo("Shared Levels and Grids") == 0) || (item.Name.CompareTo("1/4 SCOPEBOX AND MATCHLINE") == 0) || (item.Name.CompareTo("1/8 SCOPEBOX AND MATCHLINE") == 0))
                            {
                                lstWkSet_Close.Add(item.Id);
                                continue;
                            }
                        }
                    }
                    wk.Close(lstWkSet_Close);
                    _RvtLinkType.LoadFrom(_modelpath, wk);
                }

            }
            catch (Exception e)
            {
                TaskDialog.Show("dd", e.Message);
                return;
            }
            return;
        }

Draw a Property line

$
0
0

Is any one have an idea to draw property lines programatically for Revit 2019 ??

Re: Place family instance into RVT file

$
0
0

You need to first load your family into Revit.

Then get the symbol and create an instance of family as shown below.

uiApp.ActiveUIDocument.Document.LoadFamily(GlobalVariables.FamilyPath + "Grid_Mass.rfa", out fm);

FamilySymbol MassISymbol = GetSymbol("Grid_Mass", "Grid_Mass");

 

FamilyInstance MassInstance = Doc.Create.NewFamilyInstance(new XYZ(0,0,0), MassISymbol, level, Autodesk.Revit.DB.Structure.StructuralType.UnknownFraming);

 

public FamilySymbol GetSymbol(string FamilyName, string TypeName)
{
try
{
FilteredElementCollector collector = new FilteredElementCollector(Doc).OfClass(typeof(FamilySymbol));

List<FamilySymbol> symbols = collector.ToElements().Cast<FamilySymbol>().ToList().Where(item => item != null).ToList();

var query = from item in symbols where item.Name == FamilyName  && item.FamilyName == FamilyName select item;

FamilySymbol symbol = query.FirstOrDefault() as FamilySymbol;

if (symbol != null)
{
using (Transaction actrans = new Transaction(Doc, "Activate Symbol"))
{
actrans.Start();

if (symbol.IsActive == false)
symbol.Activate();

actrans.Commit();
return symbol;
}
}
}
catch { }


return null;

}

 

Re: Draw a Property line

$
0
0

Hi  ,

A wish list item was already raised for it in the past:CF-1612 [Creating and editing Property Line using API].

https://forums.autodesk.com/t5/revit-api-forum/create-property-line-programmatically/td-p/5600736 

https://forums.autodesk.com/t5/revit-api-forum/how-to-create-property-line-by-using-api/m-p/7907679 

 

you can also achieve this task using Revit postable command

 RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.PropertyLine);
 uiapplication.PostCommand(id);

I hope this helps.

 

Re: Shortcut for Finish button from UIDocument.Selection.PickObjects()?

$
0
0

:

Actually it can be done! But the safety of the following solution is not guaranteed:

// Codes working for this funcion in our product has been highly wrapped with annoying complexity

Let's ask "Spy++" for some help.

This tool should be named as "spyxx.exe" or "spyxx_amd64.exe" if the C++ desktop develop workload has been installed:

2019-12-02_150300.png

Then we can check some detailed infomation of the "Finish" button:

2019-12-02_150912.png2019-12-02_151247.png

Once you have recursively searched all children windows of Revit Windle, and got the Finish Button, send a CLICK message to this button (window):

SendMessage(revitHandle, 0x00F5, new IntPtr(0), IntPtr.Zero);
// revitHandle can be accesed easily in 2019 API

++ This solution works fine from Revit 2016 to 2020 ++

But safety is still not guaranteed 🙂

Re: Draw a Property line

$
0
0

Thanks Naveen.

I tried out post command its working.

But could you please tell me ,how to pass co-ordinates to Post Command ????

 

How to join ModelLines?

$
0
0

I want to join ModelLines..!

캡처.PNG

 The picture consists of six ModelLines... like that! only one model line!

<Autodesk.Revit.DB.ModelLine object at 0x0000000000000110 [Autodesk.Revit.DB.ModelLine]>
 
ps)May I use this function 'JoinGeometry'??
    +I want to know how to save ModelLine's element!

Re: Draw a Property line

$
0
0

Hi  ,

Unfortunately, I am sorry to say that the PostCommand functionality does not accept passing parameters to the PostCommand() method. The method will just launch the built-in/add-in Revit command as it is, including all its user interaction.

It does not include any possibility to supply any additional input arguments or programmatically define the selection, it will prompt the user for the standard manual interaction, just like Revit normally would.

 

You can refer this blog for more information

https://thebuildingcoder.typepad.com/blog/2013/10/programmatic-custom-add-in-external-command-launch.html

Re: Revit API - C# - Sun and shadow setting - calculating sun direction

$
0
0

Thanks for the reply! I got it solved by change the datetimespecify.Utc to datetimespecify.local. 

 

 

How to detect if family is line based in family document

$
0
0

How to detect if family is line based in family document?

Re: How to detect if family is line based in family document

$
0
0

switch (famdoc.OwnerFamily.FamilyPlacementType)
{
case FamilyPlacementType.Adaptive:
return false;
case FamilyPlacementType.CurveBased:
return false;
case FamilyPlacementType.WorkPlaneBased:
return false;
default:
return true;

}

Re: Revit API - C# - Sun and shadow setting - calculating sun direction

$
0
0

Congratulations and thank you for letting us know.

 

Re: How to join ModelLines?

$
0
0

If you are asking how to join the six model lines into one single element, I must say that I do not believe that is possible.

 

However, the first thing you should always do to research how to solve a Revit API programming task is to find out how to address the issue optimally and using best practices manually through the end user interface.

 

Can you join those six lines manually in the user interface to one single element? 

 

If so, use RevitLookup to explore how that element is represented in the Revit database.

 

If not, it is probably not possible programmatically through the API either.

 

Re: Is a model Workshared without opening the file


Re: Duct system

$
0
0

Sorry

It was MechanicalSystemType

How to get correct Transform of Family Instance?

$
0
0

Hi everyone,

     I am trying to export the model to third party render engine.In order to reduce file size,I export the geomtry only once for those family instance which use the same family symbol.So I need to get the correct Transform of the faimily instance.I use "FamilyInstacen.GetTotalTransform" Method to get Transform.In most cases,it works well.But,sometimes it does't work,especially for those mirrored family instances.It seems that the total Transform does not count the mirror.The Property "FamilyInstance.Mirrored" tell me some family isntances is mirrored.But I can't find any Method to konw how does the instance been mirrored or which axis is flipped.

     So,my question is how to get the correct Transform? Is there anything been ignored?

 

Re: Generate Views from Rooms.

$
0
0

I regret using CreateViaOffset method taking a list of doubles with offsets set as Wall.Width *1.1 results in an error when the wall width changes across its length.

 

I have been examining the results returned from
foreach( BoundarySegment s in sloop )

For room 2 there are 5 curves returned as expected (1 for each wall/boundary)
For room 4 there are 8 curves returned (6 for each wall/boundary/room separator)
Upon examining the 2 remaining curves these return elem == null.
In order to retain the continuity when undertaking CreateViaOffset(CurveLoop, IList<(Of <<'(Double>)>>), XYZ) a value needs to be set for the 2 null elements. The result of providing positive and negative values can be seen in images 1 and 2.
If the room separator is replaced by an alternate wall type then there are no null returns.

Image - 1.png                      Image - 2.png

Unfortunately I still cannot get the crop region to return in these instances i.e. back in towards the room separator, without Curved Loop could not be properly trimmed error. As long as the width is equal to or greater than the previous width when there are changes across the length there are no errors.
In order to explore this the code was amended in accordance with the attached. Its rough and ready but demonstrates the problem.

Re: Filter elements by parameter value

$
0
0

Hi! Pls, help. I am trying to get all families wych belong to the Model category type. I am trying to do it via:

 

			FilteredElementCollector families
				= new FilteredElementCollector( doc )
				.OfClass( typeof( Family ) )
				.Cast<Family>()
				.Where( e => e.FamilyCategory.CategoryType.Equals(CategoryType.Model) );

but I get compile error:

 

error CS0266: Cannot implicitly convert type "System.Collections.Generic.IEnumerable<Autodesk.Revit.DB.FamilyInstance>" to "Autodesk.Revit.DB.FilteredElementCollector"...

I am not so strong in c# & Revit API yet - could you point what I am missing?

 

Revit 2019, ShardDevelop

Flip Pipe Fitting

$
0
0

Hi all,

 

I am currently working to develop a simple command to flip elements that have a flip control. I have used Family Instance flipfacing() with success for duct takeoffs, but I cannot get the command to work with a 90° sweep tee for piping. I have also tried fliphand() without success. Any suggestions?

 

Thanks!

Viewing all 66784 articles
Browse latest View live


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