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

Is it possible to disable the delete command of the views?

$
0
0

Hi Masters,

 

Is it possible to disable the delete commend of the views (Floor plan, Section 3D Views ect..,).

Or is there any other ways to prevent deleting of views?

 

While I submit my model to other contractors for review, they accidentally deleted some of the floor plans and I lost all our hard work (Shop Drawing) of a week.

 

Please assist me to fix this problem.

BEP, Workflow, Flow diagram doesn't help to resolve this problem.

 

I believe the only way to resolve this is to bring it under control. Like Work sharing.

 

17.JPG


Re: How do I start using Macros from the internet?

$
0
0

Probably your module name is the same as the macro name.

Rename your module name (namespace) to something different.

 

module_and_macro_must_not_be_the_same_name.png

 

  

Re: Comment Duct accessories

$
0
0

Hi ,

 

I've tried your code and nothing wrong happened. It works as you want.

 

I've never experienced any problem using it.

 

Maybe you have another piece of code wich causes this bug ?

 

Cheers,

 

GM

Re: Is it possible to disable the delete command of the views?

$
0
0

Hi!

 

It is not possible to disable the button, but you can track elements deletion via dynamic model updater and post error when elements are being deleting. You need to get all views ids on document open and after synchronization (register event handlers), store it somewhere and check if any of ids of deleted elements are in this list.

Re: Comment Duct accessories

$
0
0

Thanks for your reply.  Indeed i tried on another project file and it works ... sorry for this useless post.

Re: When will Revit have Full .ITM functionality...

$
0
0

I realize this post is a couple years old but am researching this process right now. Revit 2018 now has a workaround to export to a .pcf file which our pipe fab shop can utilize in Acorn to send to the pipe cutting machines http://blogs.autodesk.com/revit/2017/07/26/exporting-pcf-files-from-revit/ I've tried it and it's a pretty easy process to use.

 

There's also a relatively inexpensive spooling Add-In Victaulic has been working on with Autodesk I'll be looking into more:

http://au.autodesk.com/au-online/classes-on-demand/class-catalog/2016/revit-mep/mep21462#chapter=0

 

Does anyone have any experience in these tools yet and any advice to share? I wish Revit would have had this 3 years ago when a division in our company went to Solidworks based solely on the export functionality to the shop.

Re: Is it possible to disable the delete command of the views?

Re: Is it possible to disable the delete command of the views?

$
0
0

Hi!

 

I'll show you key code concepts, but a bit later


Re: Is it possible to disable the delete command of the views?

$
0
0

Hi ,

 

Sure, no problem,

I will wait for you.

Thanks a lot

Re: How do I start using Macros from the internet?

$
0
0

sochong wrote:

Probably your module name is the same as the macro name.

 

  


Hi Sochong!No, I use two different names for Module and Macro.

 

Did you try the macro yourself?

 

No, I use two different names for Module and Macro.

"Namespace" is for the module name, right?

Or do I need to define one for the macro name as well?

 

 

If I ddon'ttype in any code inside legendOnSheets(), I won't get any errors.

 

Macro Empty.JPG

 

 

As soon as I paste in the code, I get an error

Macro Code.JPG

Re: How do I start using Macros from the internet?

$
0
0

Hi Haider,

 

Yes i had tested the macro, there seems to me nothing wrong with the code.

I had compiled succesfully in Sharpdevelop Editor.

I will insert the code completely for you to examine the whole macro.

Look where the difference are with your code, beside the different namespace name.

If you can do it, insert your whole code just like i did.

 

Good Luck!

/*
 * Created by SharpDevelop.
 * User: S. Li
 * Date: 2017-10-04
 * Time: 19:20
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;

namespace MacroFromInternet
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.DB.Macros.AddInId("CBE2490D-447D-4713-9EA4-789F888A1672")]
	public partial class ThisApplication
	{
		private void Module_Startup(object sender, EventArgs e)
		{

		}

		private void Module_Shutdown(object sender, EventArgs e)
		{

		}

		#region Revit Macros generated code
		private void InternalStartup()
		{
			this.Startup += new System.EventHandler(Module_Startup);
			this.Shutdown += new System.EventHandler(Module_Shutdown);
		}
		#endregion
		public void legendOnSheets()
		{
		    Document doc = this.ActiveUIDocument.Document;

		    // create list of element ids for the sheets that will get the legends
		    List<ElementId> sheetIds = new List<ElementId>();

		    // use SheetNumber to find the desired sheets
		    // add each sheet to the list of sheet ids
		    sheetIds.Add(new FilteredElementCollector(doc)
		        .OfClass(typeof(ViewSheet))
		        .Cast<ViewSheet>()
		        .FirstOrDefault(q => q.SheetNumber == "A101").Id);
		    sheetIds.Add(new FilteredElementCollector(doc)
		        .OfClass(typeof(ViewSheet))
		        .Cast<ViewSheet>()
		        .FirstOrDefault(q => q.SheetNumber == "A102").Id);
		    sheetIds.Add(new FilteredElementCollector(doc)
		        .OfClass(typeof(ViewSheet))
		        .Cast<ViewSheet>()
		        .FirstOrDefault(q => q.SheetNumber == "A103").Id);

		    // find the legend to put on the sheets
		    // use ViewType.Legend and the view name to find the legend view
		    Element legend = new FilteredElementCollector(doc)
		        .OfClass(typeof(View))
		        .Cast<View>()
		        .FirstOrDefault(q => q.ViewType == ViewType.Legend && q.Name == "Legend 1");

		    // create a transaction so that the document can be modified
		    using (Transaction t = new Transaction(doc, "Legends on Sheets"))
		    {
		        // start the transaction
		        t.Start();

		        // loop through the list of sheet ids
		        foreach (ElementId sheetid in sheetIds)
		        {
		            // create a new viewport for the legend on each sheet
		            // place the legend view at the 0,0,0 location on each sheet
		            // user will need to move the legend to the desired location
		            Viewport.Create(doc, sheetid, legend.Id, new XYZ(0,0,0));
		        }

		        // commit the changes
		        t.Commit();
		    }
		}
	}
}

 

 

legend_on_sheet.png 

Re: Is it possible to disable the delete command of the views?

$
0
0

Hi!

 

I've created a sample for you https://github.com/CADBIMDeveloper/RevitProhibitViewDeletions

 

It prohibits deletion of any views in project.

 

Again key concepts are Dynamic model updater and Failure processing, look at ViewDeletionUpdater.Execute

 

            var document = data.GetDocument();

            var viewCache = documents.GetCacheForDocument(document);

            if (data.GetDeletedElementIds().Any(viewCache.Contains))
                document.PostFailure(new FailureMessage(viewDeletionProhibitedFailureId));

if there is a view in deleted elements we post failure.

The other code in solution is just to maintain actual views ids for all user documents

 

Re: Revit API to edit Model Line Weights for a given scale

$
0
0

Of course I meant through the Revit API.

Re: Is it possible to disable the delete command of the views?

$
0
0

Great Bro,

 

But, I don't have any programming background.

How should I load this code into Revit?

Please advise me.

Re: Is it possible to disable the delete command of the views?

$
0
0

Hi!

 

You need to download the code from github and built it with visual studio. The solution contains post-build event, which copies dll and addin file to revit addins folder:

 

copy "$(ProjectDir)*.addin" "$(AppData)\Autodesk\REVIT\Addins\2017"
copy "$(ProjectDir)bin\debug\*.dll" "$(AppData)\Autodesk\REVIT\Addins\2017"

However, you should go deeper to programming stuff, it is not quantum mechanics or nuclear physics, it is much easier :). I don't know good courses in C#, but I think, you could find something in Coursera or other courses in internet,

 

About Revit API programming in such case suggested that you first of all take a look at the getting started material and work through the step-by-step instructions provided by the DevTV and My First Revit Plugin video tutorials:

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

 

Besides, this is the best blog about Revit addins programming, many many thanks to Jeremy


What is the name of the category hosting only straight duct ?

$
0
0

Hi everybody !

 

I would like to know the name of the category hosting only straight ducts. 

 

I've seen the BuiltInCategory.OST_MechanicalEquipment

But this is for all equipment including fitting, accessory and so...

 

Can someone help me with this please ?

 

Cheers,

 

GM

how to retrieve shared parameter values?

$
0
0

here is my situation:

 

I already created my shared parameters and using api I want to retrieve the string values.

 

anyone can help?

 

thanks a lot.

Re: how to retrieve shared parameter values?

$
0
0

Hi!

Find your parameter guid, then get parameter from element via: parameter = element.get_Parameter(new Guid("your guid value")), then you can get its value using AsString() method, if your parameter is text or AsValueString() in other cases.

How to change family symbol insertion point?

$
0
0

Hi,

 

I'd like to change the insertion point (origin) when inserting a new family symbol instance. I thought of doing multiple types with different axes to define origin, but it multiplies the number of types by 9. It's not the best choice for end user.

revit_choose_familyorigin.png

Does anyone have a solution or suggestion?

Best regards

Issue with exports for revit 2018

$
0
0

I am trying to export DWG, FBX and print PDF using an addin. All these features work without any problems in revit 17, but in Revit 2018, it crashes after export. All the exports are successful, but after the export it crashes, saying that revit is not responding. 

 

I have updated the addin using the revit 18 API. 

 

I have created wrappers around the normal UI controls like list view. These list views hold view and sheet names. The user selects the sheet/view to be exported. The export functions for all these is present in the class that wraps the UI controls. This class also holds a reference to the command data object. and any references to the document are done through this command data object (by retrieving the document object). Is there any problem with this procedure. Is the command data object still alive?

 

 

This is a code snippet for export to CAD

 

void printSelectedToCAD(string path)
        {
            List<ElementId> elementIds = GetSelectedEntitiesIds();
            if (elementIds == null) return;
            Document document = commandData.Application.ActiveUIDocument.Document;
            using (Transaction tran = new Transaction(document))
            {
                tran.Start("ExportingCAD");
if (elementIds.Count == 0) return;
string directoryName = Path.GetDirectoryName(path); string fileName = Path.GetFileNameWithoutExtension(path); DWGExportOptions dwgExportOptions = new DWGExportOptions(); document.Export(directoryName, fileName, elementIds, dwgExportOptions);
tran.Commit(); } }
Viewing all 67020 articles
Browse latest View live


Latest Images