Hi
If you are modifying an element then it should be inside the transcation.
Transaction actrans = new Transaction(doc); actrans.Start("Your transaction name"); //Your code actrans.Commit();
Hi
If you are modifying an element then it should be inside the transcation.
Transaction actrans = new Transaction(doc); actrans.Start("Your transaction name"); //Your code actrans.Commit();
Hi Maisoui,
Yes I agree, not all API are so straightforward to use and understand. I did a quick check with the solution you mentioned, it seems another way to do that, I did not try that before, it would be very nice if you could give that a try and let us know how it works, thanks.
Hi
If it solves your issue could you please accept it as solution!
Hi Jonathan,
I agree working with different Revit versions and languages this might not be the right choice.
I hope you will find your solution to your problem.
Cheers,
So-Chong
I don't know if this is the best way, but this code seems to do the job:
public bool setSegmentsDimensions(Rebar rebar, Dictionary<int, int> segmentsDimensions/* millimeters*/) { Document document = rebar.Document; //retrieve rebar shape RebarShape shape = document.GetElement(rebar.GetShapeId()) as RebarShape; if(shape == null) return false; //retrieve shape definition RebarShapeDefinition shapeDefinition = shape.GetRebarShapeDefinition(); if(!(shapeDefinition is RebarShapeDefinitionBySegments)) return false; RebarShapeDefinitionBySegments shapeDefinitionBySegments = shapeDefinition as RebarShapeDefinitionBySegments; //retrieve each segment foreach(var segmentDimension in segmentsDimensions) { if(segmentDimension.Key < 0 || segmentDimension.Key >= shapeDefinitionBySegments.NumberOfSegments) return false; RebarShapeSegment shapeSegment = shapeDefinitionBySegments.GetSegment(segmentDimension.Key); //look for length constraint IList<RebarShapeConstraint> shapeConstraints = shapeSegment.GetConstraints(); foreach(RebarShapeConstraint shapeConstraint in shapeConstraints) { RebarShapeConstraintSegmentLength shapeConstraintLength = shapeConstraint as RebarShapeConstraintSegmentLength; if(shapeConstraintLength != null) { SharedParameterElement sharedParameter = document.GetElement(shapeConstraintLength.GetParamId()) as SharedParameterElement; if(sharedParameter != null) { Parameter parameter = rebar.get_Parameter(sharedParameter.GuidValue); if(parameter != null) { parameter.Set(Unit.convertToApi(segmentDimension.Value, DisplayUnitType.DUT_MILLIMETERS)); } } break; } } } return true; }
What do you think?
Best regards,
Jonathan
The analytical model by Revit export to Robot Analysis.
When export the analytical model to Robot the software notified that “unknown run-time error”.
So, we need to extend software or will repair software
does anyone know the status on this case ?
I am still struggeling when I want to create custom sheet sizes during print.
Hi,
When I create an instance of Autodesk.Revit.DB.Analysis.AnalysisDisplayColoredSurfaceSettings and set its ShowContourLines property to true the contour lines are not displayed. The ShowGridLines property works as expected.
This problem occurs directly though the Revit API as well as through the "Modify | Analysis Results" -> "Style" -> "Edit Style" dialog that controls the instance through the Revit UI.
The Revit version I use is 2019.1 ( 19.1.0.112 , 20180806_1515(x64) )
Does anyone has had similar experiences? Any ideas how I can fix this?
Best regards,
Martin
Hello,
I have case where created long rebars are not visible, they finally have got length equals zero.
It seems it is bug, please could you check this case?
Greetings, Jaroslav.
attachments:
.rvt project,
vs solution with external command implementation,
addin manifest. (rename .xml to .addin)
Yes, indeed, I think this is not quite the right place for this question.
I think you will have more success going through the official Forge help channels, via:
https://autodesk-forge.github.io/
https://forge.autodesk.com/en/support/get-help
Cheers,
Jeremy
Hello Zhong. You have sent me an Email and I repeated you directly by email to customersupport@autodesk.com
The following is the original email.
Dear Zhong,
Sorry that I was on a short vacation and reply a little late.
Here is the code to split the wall by levels. I have written some comments, I think it is easy to understand.
Actually, I have already solved the problem. I have written it in CSWall.cs line 223.
It is because that I have set the locationCurve of the wall manually. Then the described problem comes out. It runs well when I delete the code to set the locationCurve.
I don’t know whether it is a bug in Revit. Please inform me when you have a conclusion.
And another question is about the function “Split wall by Levels”. Now my process is:
The problem is, the copied wall can keep the parameters. But the windows are newly created. If I have set some project parameters, they would get lost using this method.
Do you have any good method to copy the windows to the same spot? Or do you know how is the default function “Split” in Revit realized? Can we implement it using API?
Best Regards from Esslingen Germany,
Sicheng Zhu
Why duplicate?
It is not duplicating a existing view, but duplicating a existing ViewFamilyType.
Because I don't know which elements are on the errorId list, I want to make sure that all elements are visible. A view has a ViewFamilyType. The ViewFamilyType can have a ViewTemplate (which regulates visibility / non-visibility of categories) assigned to it, that will be applied to newly created views. As I want all elements visible, I want to use a ViewFamilyType without a ViewTemplate. To avoid messing with the model, I duplicate the first ViewFamilyType found, and remove the ViewTemplate from it. [my_type.get_Parameter(BuiltInParameter.DEFAULT_VIEW_TEMPLATE).Set(ElementId.InvalidElementId);] where ElementId.InvalidElementId is the equivalent to null for an ElementId-value. (== do not assign ViewTemplate)
Then I use this ViewFamilyType to create the 3D view.
BuiltInParameter.VIEW_PARTS_VISIBILITY
Revit has the possibility to divide (system) families into Parts http://help.autodesk.com/view/RVT/2018/ENU/?guid=GUID-DA150C6B-996C-4C70-9E8C-3C536C232851
A view can show either the original element, the parts or both. By setting the BuiltinParameter to 2, I set the view to show the original element and the parts.
Hi and sorry, I lost track of this issue for some time.
Thanks for the suggestion regarding try-catch statement, but actually that's what we always do in the outmost context of our code implementation of toolbar commands. Whenever an exception is caught in that outmost context (and if it wasn't handled in the inner implementation), we show a dialog to the customer, showing the exception content with a "Copy to clipboard"-button and guiding them to send us a mail with the content.
That's how we received the exception text in the first place:
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)
So, as far as I'm concerned, it is proven that the importImage method can throw (at least one) more exception(s) than only ArgumentNullException.
The suggestion to make a "debug plugin" for our customer is not an easy task at all, because our plugin is more like a big application consisting of different components/dll's. It would take a lot of work to deliver a debug variant. It's unlikely our management agrees to choose this way just to find more information about the type of the exception. It's a good idea, but also a question of cost and benefit.
Best Regards,
Armin
Hi, I'm trying to scale a viewport by code but it trows an exception that is not active, any idea how can I achieve activate and scale?
I tryed this way:
using (Transaction transaction = new Transaction(doc, "Scale Up")) { transaction.Start(); RevitCommandId id_addin = RevitCommandId.LookupCommandId("ID_VIEWPORT_ACTIVATE"); uiapp.PostCommand(id_addin); int scale = 1.2; doc.ActiveView.Scale = scale; transaction.Commit(); id_addin = RevitCommandId.LookupCommandId("ID_VIEWPORT_ACTIVATE_BASE"); uiapp.PostCommand(id_addin); transaction.Commit(); }
and this way:
using (Transaction transaction = new Transaction(doc, "Scale Up")) { transaction.Start(); ViewSheet vs = doc.ActiveView as ViewSheet; Viewport legendVP = new FilteredElementCollector(doc).OfClass(typeof(Viewport)).Cast<Viewport>().Where(q => q.SheetId == vs.Id).First(); int scale = 1.2; legendVP.GetBoxOutline().Scale(scale); }
Regards!
I think I figured it out: The ContourLines that can be activated by this command seem to be the "outline" of the surface that got analytically colored. We expected somehow that this property turns on something like "isolines" representing contours in some cases.
If someone can support this view, this request is closed.
Best regards,
Martin
I'm testing a static code (Python) to re-assign level to Conduits + Conduit Fittings that were placed by BIM operators to a Level that we want to be changed.
When I run to code on a Conduit Fitting that is not connected to other Conduits, everything works fine (Conduit Fitting is maintaining same z)
Once I run the code on a Conduit Fitting that has Conduits attached to it, they move up (z changes).
Below is the Python code:
# CONDUIT FITTING TO TEST Id = 9803491
EL_ID = ElementId(9803491)
# SELECT THE CONDUIT FITTING TO TEST
MY_EL = doc.GetElement(EL_ID)
# B_FOOTING = CURRENT REFERENCE LEVEL FOR THE CONDUIT+CONDUIT FITTINGS
# FIRST_FLOOR = LEVEL WHERE I WANT THE CONDUIT+CONDUIT FITTINGS RE-ASSIGNED
# LEVEL ID WHERE I WANT MY CONDUIT FITTING TO BE SET
FIRST_FLOOR_LEVEL_ID = 355
t = Transaction(doc, 'SET LEVEL')
t.Start()
OFF_SET = - FIRST_FLOOR_LEVEL_ELEV + B_FOOTING_LEVEL_ELEV + i.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).AsDouble()
MY_EL.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM).Set(OFF_SET)
MY_EL.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).Set(ElementId(355))
doc.Regenerate()
t.Commit()
Help greatly appreciated.
Thank you.
I want to get the exterior floor area above the room using API.
Assumed that the floors are modelled separately and I already know which floor is an exterior floor.
And I want a common solution. Sometimes the floor area is the same as the room area. Sometimes its projection is within the room boundaries. Sometimes they have intersections.
Perhaps we can use the Class SolidCurveIntersection to get the intersected Curves and discuss in situations.
Perhaps you can figure out some better solutions.
Hi
Thank you for sharing your code.
It seems to me a good solution.
Indeed, this is 'safer' than string comparison.
Using The RebarShapeConstraintSegmentLength Class and some other Classes you mentioned, you are better equipped to get the rebar segments dimensions.
Regardless which language and version of Revit you use.
However, the GetShapeId Method was introduced in 2018(Revit version).
You have customized code for customers using earlier version than 2018?
Best regards,
So-Chong
Jim, here is my attempt at a minimal reproducible case. The attached zip file should contain all the files needed, including the source code.
FAIR59, I think I understand your sample code, but I am struggling to implement it. How did you pass in the UIApplication when you setup/registered TestUpdater?