TaskDialog and FileName

TaskDialog and FileName

minet.axel
Enthusiast Enthusiast
2,492 Views
10 Replies
Message 1 of 11

TaskDialog and FileName

minet.axel
Enthusiast
Enthusiast

Hello,

The TaskDialog does not display the full path, do you have a solution?

thank you.

 

public class TestPath
    {
        public string Extension
        {
            get
            {
                return ".rfa";

            }
        }

        public string FamilyFolder
        {
            get
            {
                return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Support\\";
            }
        }

        public string FamilyPath
        {
            get
            {
                return FamilyFolder + FamilyName + Extension;
            }
        }

        public string FamilyName
        {
            get
            {
                return "MyFamily";
            }
        }
    }
  TestPath tp = new TestPath();
                if (!File.Exists(tp.FamilyPath))
                {
                    TaskDialog d = new TaskDialog("Error");
                    d.TitleAutoPrefix = false;
                    d.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
                    d.MainInstruction = string.Format("{0} not found in {1}.", tp.FamilyName, tp.FamilyFolder);
                    d.Show();
                }

error family.PNG

0 Likes
2,493 Views
10 Replies
Replies (10)
Message 2 of 11

jeremytammik
Autodesk
Autodesk

Use MainContent instead of MainInstruction:

 

http://www.revitapidocs.com/2017/0c2eb583-de3d-58f5-31ea-7ff71eae51a5.htm

 

Refer to this article for an example of using it:

 

http://thebuildingcoder.typepad.com/blog/2016/10/list-material-asset-texture-and-forge-webinar-recor...

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 11

minet.axel
Enthusiast
Enthusiast

I also tried with "MainContent" but the result is the same. 

 

 

I made 2 examples:
1st example: familyPath in MainContent (same result), no "back to line"

2nd example: Description of the method "LoadFamily Method (String, Family)", there is "back to line"

 

error family 3.PNG

 

0 Likes
Message 4 of 11

jeremytammik
Autodesk
Autodesk

Oh, you mean that you wish to break the line?

 

That is easy!

 

Just use the Windows default carriage return + linefeed to force a line break, i.e.:

 

  string s = "first line" + "\r\n" + "second line";

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 11

minet.axel
Enthusiast
Enthusiast
what i mean is that the path is not visible totally in the 1st taskdialog while the description of the method is visible totally in the 2nd taskdialog. The 2nd taskdialog automatically returns to line.
0 Likes
Message 6 of 11

harrymattison
Advocate
Advocate

There is the same problem with MainContent. The long string (a file name) is being truncated with ...

See attachment

0 Likes
Message 7 of 11

jeremytammik
Autodesk
Autodesk

I would suggest avoiding displaying such a long path visually to the end user at all.

 

What is she supposed to do with it?

 

No human being can reliably read such a long string on a regular basis without overlooking something.

 

So why display it at all?

 

You can just as well display some hints, e.g., the filename and containing folder name, and a button to copy the full path.

 

What is your intended workflow, and how is this message supposed to be used and aid in that?

  



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 11

jeremytammik
Autodesk
Autodesk

If the Revit TaskDialog does not suit your needs, you can always use a Windows MessageBox instead, or create your own modal Windows form to convey the required information and functionality...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 9 of 11

tyler.largeteau
Explorer
Explorer

How would one implement a button to copy the filepath into TaskDialog?

0 Likes
Message 10 of 11

jeremy_tammik
Alumni
Alumni
  • Implement a button
  • Copy the required data
  • Paste the required data

 

Which step is unclear to you?

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 11 of 11

lionel.kai
Advisor
Advisor

The short answer is to just use

System.Windows.Forms.MessageBox.Show(contents,title);

instead of

TaskDialog.Show(title,contents);

Note the switched title/contents order (add a "using" to eliminate "System.Windows.Forms.").

 

Long answer:

 

TaskDialog's behavior is inconsistent and unreliable. After experimenting with various options, it appears that setting ExtraCheckBoxText (to ANY value) causes all other fields to NOT truncate [see 3 rightmost example screenshots], so you could set it to something like "ignore this checkbox" or just put your entire message in there instead.

 

Something similar happens with VerificationText, except that the behavior depends on the length of the text. Setting a long string causes OTHER fields to not truncate, and appears to also expand the width of the dialog, but VerificationText still truncates AND wraps [see bottom-left example]. If you set VerificationText to something short, it doesn't have any impact [see middle-right example].

 

It would be nice if we could determine the behavior by setting a property, or if we could just put long paths in ExpandedContent, for example.

 

To answer the "why?":

 

These kinds of quick-and-dirty dialogs are usually used when debugging to check values of various parameters, or to indicate progress. Sometimes I leave one in so that the user "knows something happened", but the contents are mainly for me. In this case, I wanted to verify that the path was to the new "bundle" folder in "ApplicationPlugins" instead of the old version-specific folder (and I didn't remember off-hand where each path started, so the truncated path was useless to me). TaskDialog vs MessageBox more comparisons - censored.png


Lionel J. Camara
BIM Manager at KAI Hawaii, Inc. - Structural and Forensic Engineers
Autodesk Certified Professional