NewDimension in family document - Invalid number of references

NewDimension in family document - Invalid number of references

juhanak
Participant Participant
5,159 Views
35 Replies
Message 1 of 36

NewDimension in family document - Invalid number of references

juhanak
Participant
Participant

Hi,
NewDimension method gives "Invalid number of references" error from Revit 2023 API when using it in Family document. Previous versions of API didn't give this error. Reference array contains 2 valid items. View is active view of family document. View parameter is changed in this API version a little bit so I tried to use also null value with SketchEditScope but I hit to another problem. SketchEditScope is allowed only in project document - not in family document. 

 

Is there any workaround or tips how to add dimension line between 2 Model lines in family document by using Revit 2023 API?

 

I added ZIP file where is a family document and CS source file with AddDimToModelLines method for testing purpose. 

5,160 Views
35 Replies
Replies (35)
Message 21 of 36

mariya_petrova
Autodesk
Autodesk

@juhanak, I noticed you mentioned issues using Document.Create.NewLinearDimension. I suspect there is a problem with dimensions created by this method in sketches. This is likely a different problem and needs to be looked at separately. Would you please send the code sample which you used to create the sketch dimensions with NewLinearDimension? Thank you!

0 Likes
Message 22 of 36

juhanak
Participant
Participant

Hi Mariya

 

I attached here RFA. Macros are inside of RFA file. This includes 4 different problems. One with a nut shape and two with blend, and 1 with view.

 

A nut case:

  1. Open Floor plan in the Family editor.
  2. Execute SetDimForNut() macro. It will add dimension lines between exiting reference lines and extrusion sketch entities. "R_6" family parameter is set to the Family Label of each dimension.
  3. There is not any message when the macro has ended. So verify in this phase that all dimensions are ok, like here:

juhanak_0-1662029111933.png

 

  1. Open Family Types dialog
  2. Change Type Name to "Nut-2". Notice that "R_6" family parameter have different value.

=> Errors should occur as soon as OK or Apply button is pressed:

juhanak_1-1662029111940.png

 

 

Blend case:

Even that we are demonstrating here with Blend this will occur also with Extrusion and Revolve if there is Arc used in the model.

  1. Open "Section 1" view. (Macro is using ActiveView property)
  2. Execute SetDimForBlend() macro. First it will add Reference lines and then it will add dimension lines between reference lines and Arcs. "H" family parameter is set to the Family Label of each dimension.

=> Errors should occur immediately:

juhanak_2-1662029111942.png

 

 

2nd Blend case:

  1. Open "Section 1" view. (Macro is using ActiveView property)
  2. Modify SetDimForBlend() macro so that there will be 2 separate transactions. See the comments in the macro.
  3. Execute SetDimForBlend() macro.

=> Same kind errors occurs but now it shows to another Arc than when there was only 1 transaction in use:

juhanak_3-1662029111945.png

 

 

View case:

Both Blend cases uses ActiveView in the macro. And selected view was “Section 1” view. With Revit 2022 we have used “{3D}” view when we are creating RFA. There it has been worked well.

With Revit 2023 these Blend test case will fail if active view is 3D. So select that view and  run the SetDimForBlend() macro. This error occurred:

juhanak_4-1662029111947.png

Br Juha

 

0 Likes
Message 23 of 36

mariya_petrova
Autodesk
Autodesk

Hi @juhanak , 

 

Thank you for providing the file and macros. I see the problems you describe.

 

In short, my comments are the following:

  • NewLinearDimension has issues in 2023, which is unfortunate, as you cannot use it for a workaround in these cases. Did you use NewLinearDimension successfully for these operations in 2022? If so, would you also send us the file/macro which successfully uses NewLinearDimension in 2022? My guess is that this never worked, and it is a separate issue that will need to be solved.
  • The version of NewDimension, which I have repaired locally, works for the cases you provided, except for the 3D view case. The 3D case does not work out of the box with the repaired NewDimension either, because in order to place dimensions in 3D view, you need to set the active workplane to the plane of the sketch in which you'll be placing the dimension. Once I named the reference plane on which the blend was placed and set it as active workplane in 3D view, that case worked too. For further reference, when working in 3D view, please make sure to set the active workplane first, to avoid errors. This forum post talks about how to create workplanes from scratch, or use existing workplanes: https://forums.autodesk.com/t5/revit-api-forum/set-active-work-plane/td-p/3818199

 

FYI, here are some screenshots from my testing with the repaired NewDimension, so I am confirming it should work for these cases once fixed.

 

After making the dimensions, they look normal in the sketch:

mariyapetrova_0-1662038265582.png

 

 

 

After the type is changed to Nut-2, there are no errors and the shape changes:

mariyapetrova_1-1662038355171.pngmariyapetrova_2-1662038437974.png

 

Adding dimensions to the second blend in section:

mariyapetrova_3-1662038726209.png

 

 

 

0 Likes
Message 24 of 36

juhanak
Participant
Participant

Hi @mariya_petrova 

 

Models look ok in your screenshots.

You are right, NewLinearDimension is not working in 2022. However I attached here rfa and macros for Revit 2022 which uses NewDimension. A nut will work but a blend is not working. I don't know it this is something new case or what is the reason. Same messages comes what appeared in 2023.

 

About 3D view, yeah macro was not perfect. I still want to clarify that if I am not using UI at all when creating rfas, is it ok and needed to call ShowActiveWorkPlane method for the view?

 

Br Juha

Message 25 of 36

mariya_petrova
Autodesk
Autodesk

Hi @juhanak

 

Thank you for the R2022 sample. After looking at it, turns out that one of your methods, CreateDimension, was still using NewLinearDimension. I've updated the macro to use NewDimension, and now the method works on the blend, please see attached.

 

To summarize:

  • NewLinearDimension has not worked in 2023, as well as 2022, and perhaps in prior releases. There is a problem with this method that needs to be looked into separately. I am going to direct this issue to the team which owns it. If you feel like it needs to be addressed soon, please file a separate ticket with support to escalate the issue.
  • NewDimension works in 2022 on the samples you've sent me. And it also works in 2023, after I've applied the fixes to the method. Those fixes are planned to ship with 2023.1

 

As far as the 3D view usage goes, I think you can skip calling ShowActiveWorkPlane. It is important that you've set it to the plane with the correct orientation, but showing it is optional.

 

Thanks and please let us know if you have any other issues.

0 Likes
Message 26 of 36

jorn2B4KZ
Participant
Participant

Hello, are there any more information on the release date of revit 2023.1? and does it include a fix for this issue? 

0 Likes
Message 27 of 36

Campus_Varberg
Observer
Observer

Hi, MagiCAD 2023 for Revit 2023 release depends on when AutoDesk releases Revit 2023.1. 
Any updates regarding the release of 2023.1? Any timeline?

Message 28 of 36

mariya_petrova
Autodesk
Autodesk

Hello @jorn2B4KZ and @Campus_Varberg, we plan on addressing this issue in the next update for Revit 2023.  We cannot confirm a date for its release.  We appreciate your patience as we work to address the issue.

0 Likes
Message 29 of 36

evaNQT83
Contributor
Contributor

Is this fixed in the new 2023.1 release? 

0 Likes
Message 30 of 36

Jan_Back
Participant
Participant

Where do You find the Revit 2023.1 release update?

0 Likes
Message 31 of 36

evaNQT83
Contributor
Contributor

The release is in my Autodesk Desktop App and on my Autodesk Account Page. It was released yesterday.

0 Likes
Message 32 of 36

mikael.ekenberg
Participant
Participant
This case have now been tested with Revit 2023.1 and everything works fine with MagiCAD MEP 2023 UR-1. The new version of MagiCAD will be published on our download portal during next week. (Preliminary Tuesday)
Message 33 of 36

jonatan.jacobssonXLU42
Explorer
Explorer
Well done Mikael 👌
0 Likes
Message 34 of 36

mariya_petrova
Autodesk
Autodesk

@mikael.ekenberg , thank you for the confirmation, this is great to hear!

0 Likes
Message 35 of 36

mikael.ekenberg
Participant
Participant

@mariya_petrova Yes it was great to finally have that issue solved. 

BTW, do you happen to know something about this case?
https://forums.autodesk.com/t5/revit-mep-forum/handling-of-nested-generic-annotations-in-face-based-...

0 Likes
Message 36 of 36

mariya_petrova
Autodesk
Autodesk

@mikael.ekenberg , I am not familiar with the nested family issue. Since this looks like a significant issue for MagiCAD, I would recommend reaching out directly to support and filing a case, to get this to the correct team as soon as possible. 

0 Likes