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

Opening Form automatically when Revit Command is completed

$
0
0

I want to do some thing like:

 

MyWindow wnd = new MyWindow(viewModel);

wnd.ShowDialog();

 

in this window there is a button that call The Revit Command (Adjust Analytical Model):

 

private void CorrectButton_Click(object sender, RoutedEventArgs e)
{
MyWindow.GetWindow(this).Hide();

MyApplication.PostCommand(RevitCommandId.LookupPostableCommandId(

PostableCommand.AdjustAnalyticalModel));
}

 

When the Funktion Adjust Analytical Model is closed, the window open automatically:

 

wnd.ShowDialog();

 


Re: Ask user for element selection while a Winform is showing ?

$
0
0

I have a similar issue.  I have an Revit Addin that launches a WinForm.  Typically i use ".ShowDialog()" to launch the form, however when I used that to open my form it didn't allow the button my form to work properly.  The button is supposed to hide the form & let the user select an element in the Revit view, however with ".ShowDialog()" no window became active.  The form hides & I see all of my open windows (Files Explorer, Email etc.) but nothing is selectable.

 

To solve this my addin is using ".Show()" instead.  And when the button is clicked in my WinForm i use "this.Hide()" & "this.Show()".  This all works correct now where the form hides & the Revit window is my main window, where I can select an element.

 

But, now I have another big issue - performing an action/method on the elements I selected inside my transaction.  When I click another button in the form to perform this action is now says:

"starting a transaction from an external application running outside API context no allowed"

 

I have never seen that before, and I am assuming it is because my addin is using ".Show()", not ".ShowDialog()".  Not sure of a solution here, any help would be appreciated.

Re: TaskDialog.EnableMarqueeProgressBar

$
0
0

  - was that method mentioned by ADSK

TaskDialog_Methods_NET_5.JPG

TaskDialog_Methods_Revit_2020_1.JPG

development team?

neither .NET or Revit API, shows that method available. Maybe I'm missing something.

Re: Ask user for element selection while a Winform is showing ?

$
0
0

Truth of the matter is for what you are saying you need to do you can achieve this by not exiting the Revit API context and recreating the window. You should close not hide the window and then loop back to the point of window creation in order to remain in the context. After recreating your window you can rebind it to your updated data model.

 

If you are using modeless forms with .Show then you should implement External Events to interact with Revit. In that approach you are letting the External Command that initially shows the dialogue to exit the context. You then communicate with Revit via raising external event that creates a new context when Revit is ready.

 

As noted in first paragraph however you can stay within the context via .ShowDialog for what you want to do. Code below is VB but you can achieve the same in C# with a while loop.

 

Private Function TObj76(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Result If commandData.Application.ActiveUIDocument Is Nothing Then Return Result.Cancelled Else Dim UIDoc As UIDocument = commandData.Application.ActiveUIDocument Dim Doc As Document = UIDoc.Document Dim Res As List(Of String) = Nothing Again: Dim SelectItemWin As New SelectElementsWindow SelectItemWin.ListBox_Results.ItemsSource = Nothing SelectItemWin.ListBox_Results.ItemsSource = Res SelectItemWin.ShowDialog() Select Case SelectItemWin.Result Case SelectElementsWindow.DiaResult.SelectElements Dim R As New List(Of Reference) Try R = UIDoc.Selection.PickObjects(Selection.ObjectType.Element) Catch ex As Exception End Try If R Is Nothing = False Then Res = New List(Of String) For i = 0 To R.Count - 1 Res.Add(CStr(R(i).ElementId.IntegerValue)) Next End If GoTo Again Case Else End Select Return Result.Succeeded End Function

External Command

 

Public Class SelectElementsWindow Private IntRes As DiaResult = DiaResult.None Public ReadOnly Property Result As DiaResult Get Return IntRes End Get End Property Public Enum DiaResult None = 0 SelectElements = 1 End Enum Private Sub Button_Select_Click(sender As Object, e As RoutedEventArgs) Handles Button_Select.Click IntRes = DiaResult.SelectElements Me.Close() End Sub End Class

Window Code Behind

<Window x:Class="SelectElementsWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:RPT_RvtTests" mc:Ignorable="d" Title="Select Elements" Height="195.882" Width="427.647" WindowStyle="ToolWindow" ResizeMode="NoResize"><Grid><Button Name="Button_Select" Content="Select" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"/><ListBox Name="ListBox_Results" Margin="10,35,10,10"/></Grid></Window>

Xaml for window

 

 

Combine Pipe Elements Seamlessly

$
0
0

I seem to be struggling with combining two pipe elements seamlessly.

 

Let's say I have two pipes that had a coupling between them but are otherwise of uniform pipe type, diameter, etc... I would like to programatically delete the coupling and join the pipes together into a continuous run. Essentially the opposite of PlumbingUtils.BreakCurve

 

In the UI if you delete the coupling then drag one end onto the other it will work as desired and turn the two pipes into one continuous pipe length.

 

I have tried a number of approaches and must be overlooking something simple.

 

If you use Pipe.Create between the two pipe connectors it will create the short segment of pipe and connect them, but you now have three pipes.

 

If you modify the Location.Curve of one pipe to extend it to the end of the second pipe and use Connector.ConnectTo you end up with 2 pipes still.

 

Trying to manual send Document.AutoJoinElements() does not appear to do anything.

 

Attempting to mimic the result from the manual UI input is important to maintain any additional Tap connections etc... so replacing the second pipe by extending the first pipe and remaking all connections is preferably avoidable. When performing the action via the UI the new seamless pipe has the same ID as the dragged extended pipe (expected) and all taps that were previously on the second pipe maintain their original ID implying they were not recreated.

Problem with create Section View

$
0
0

Also, interested to know. Any solution yet ?

Re: Opening Form automatically when Revit Command is completed

No Color In 3D view

$
0
0

I can't see any color in my 3d view. How can i fix this


i cant find my student serial number, could you send me a new 1 asap thx

$
0
0

So I've just downloaded Revit from the 'student area' and I've not got any serial number or anything like that ive confirmed my student id and I've got nothings please help.

 

Thanks

Re: Combine Pipe Elements Seamlessly

Re: i cant find my student serial number, could you send me a new 1 asap thx

$
0
0

Unfortunately, this is not the best place to ask such a question.

 

Please note that this discussion forum is dedicated to programming Revit using the Revit API.

 

Therefore, you cannot expect an answer to a question such as yours relating to installation, product usage or end user support issues here.

 

You should try one of the non-API Revit product support discussion forums instead for that:

 

https://forums.autodesk.com/t5/revit-api-forum/this-forum-is-for-revit-api-programming-questions-not-for/td-p/5607765

 

The people there are much better equipped to answer your question than us programming nerds.

 

I hope this clarifies.

 

Thank you for your cooperation and understanding.

 

Best regards,

 

Jeremy

 

Re: No Color In 3D view

$
0
0

I does not sound as if you are doing anything programmatically with the Revit API, are you?

 

If not, then unfortunately, this is not the best place to ask such a question.

 

Please note that this discussion forum is dedicated to programming Revit using the Revit API.

 

Therefore, you cannot expect an answer to a question such as yours relating to installation, product usage or end user support issues here.

 

You should try one of the non-API Revit product support discussion forums instead for that:

 

https://forums.autodesk.com/t5/revit-api-forum/this-forum-is-for-revit-api-programming-questions-not-for/td-p/5607765

 

The people there are much better equipped to answer your question than us programming nerds.

 

I hope this clarifies.

 

Thank you for your cooperation and understanding.

 

Best regards,

 

Jeremy

 

Re: TaskDialog.EnableMarqueeProgressBar

Re: Boolean Operation Fail

$
0
0

     

 

I'm also facing this issue right now.  I hope the following experience could be helpful to any of you, developers or Autodesk.

 

This is my situation, a grey box containing several green cuboids. See the rendering gets a bit weird at interfacing area due to overlapping. BooleanUtil fails on the second cuboid when computing intersection between grey box and these cuboids (I wish I could give you these elements, but they're all linked. I'll try to put them in a sample file to help others recreating the problem if anyone is interested.)

 

jshial_1-1592882483937.png

 

Exception thrown, inaccuracy, misalignment. 

 

So this is what I tested:

1. Translate cuboid's solid just a little bit. Or scale it to 1.1 or 0.9. Same exception thrown, I guess a little bit of transformation didn't resolve what exception message says.

 

2. Run same logic in Dynamo (with nodes), it works fine.

 

3. Run same logic in Dynamo (with only one Python node, pure IronPython, calling BooleanUtil from RevitAPI), it works fine surprisingly.

 

Idk why even calling BooleanUtil straight from Revit API in Dynamo doesn't throw that exception anymore either. Is there some optimization that Dynamo does intentionally to cope with this problem?  I did some diggin on both Revit and Dynamo's geometry kernel, a term ASM(Autodesk ShapeManager) comes up,  this thread has some very informative discussion: https://github.com/DynamoDS/DynamoRevit/issues/1960

 

kronz's post might explain what I'm experiencing now.

 
 

 

To sum it up:

1. To revit users and developers, I would suggest to give Dynamo a try.

2. Not knowing how internal collaboration is in Autodesk, wish Revit dev team could discuss this with Dynamo dev team, hopefully releasing a fix asap.

3. This puts me in dilemma now because I'm developing a WPF app with these intersections. I have hundreds of this kind of grey boxes to compute intersections with its nearby elements. Operating on all the boxes is too heavy for Dynamo, forcing me to chop the task into smaller sets and run Dynamo multiple times. Although I consider an IExternalCommand in C# is faster than Dynamo script for my task, I just cannot use it.

 

1. Impact on your application and/or your development: 

It basically means I cannot develop my app, may argue that I can always implement my own algorithm for boolean operation. Pretty challenging and time-consuming, resource is a factor.

 

2. The number of users affected:

Almost 10,000 employees, expected product could make our work tremendously easier.

 

3. The potential revenue impact to you:

Hard to measure. Dynamo to the rescue while the efficiency dropped considerable than expected before.

 

4. The potential revenue impact to Autodesk:

Impossible for me to measure, I feel like Dynamo has a more reliable algorithm to this but don't know if transfer that to Revit is simple or not.

 

5. Realistic timescale over which a fix would help you.

As soon as possible. Timestamp in this thread, 2017 => 2019 => 2020. Development-wise, I'm stopped basically.

 

6. In the case of a request for a new feature or a feature enhancement, please also provide detailed Use Cases for the workflows that this change would address.

I just need the intersection solids, just like what BooleanOperationsUtils can give me usually.

Reading Visible Transmittance from a material / appearance asset

$
0
0

Hi everyone,

 

I'm trying to read the Visible Transmittance value for  a material with a prism glazing asset applied. I'm able to read the Transmissive Color and other values from the AppearanceAssetElement but no the Visible Transmittance. I'd guess this is because the transmittance is not set by the user, but instead calculated. However I was also unable to find a function that would calculate the transmittance value for me.

Any help in this regard would be greatly appreciated!

 

image.png

 


RabbitMQ: connect to external application from Revit

$
0
0

I am trying to connect an external application (an exe app) to Revit and vice versa in order to get some Revit element information for my app using RabbitMQ.

The idea is that I will have a producer (message sender) and a consumer (message listener) in both my external app and my custom Revit app. When the information is required, a message containing the request will be sent from the external app to the Revit app; after that, the required information will be sent from the Revit app to the external app. However, even I follow the tutorial example of RabbitMQ here , the Revit app can not create a connection for RabbitMQ, but it works perfectly fine if I create 2 separate executable apps for producer and listener.

I am at the early stage and just using localhost with default port for my apps and they only run on the same machine. What could possibly be wrong in my case? Thank you all in advance

Re: Problem with create Section View

Re: Boolean Operation Fail

Re: Boolean Operation Fail

$
0
0

Thank you very much for your careful analysis and interesting results, which I attached it to the development ticket REVIT-122714 [Boolean Operation Fail - case 13578517].

  

I am glad to hear that it works better in Dynamo, and hope very much that will help enable the Revit development team to improve the situation inside the pure Revit API.

   

Change the row height and column width in Revit Schedules

$
0
0

Hello,

I have a schedule and I would like to change its appearance and resize its cells.

 

I have read that it is not allowed to change its appearance programmatically  and I should apply a template. 

But is it possible to resize row height? what about to bold the header or change text-align? 

 

Thanks

Viewing all 66677 articles
Browse latest View live