PostCommand do not have reaction

Anonymous

PostCommand do not have reaction

Anonymous
Not applicable

Hi.

 

I want to do Solid Extrusion by Post command, My step is following :

 

1. Create a profile in Revit Family Document

1.createProfile.png

 

2. Select the profile

2.select.png

 

3. Run my adding execute Post command to form Solid.

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application; 
            RevitCommandId cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.SolidExtrusion);
            uiapp.PostCommand(cmdId);              
            return Result.Succeeded;
        }

 

 

But the results is nothing and no exception too,

How can I correctly form solid ?

 

thanks

 

 

 

 

0 Likes
Reply
Accepted solutions (1)
815 Views
13 Replies
Replies (13)

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @Anonymous ,

Your code works fine for me.

Use try-catch and see whether you get any error !!!!!

You are saying nothing is happening after executing your command so my question is "Is your addin file contains the correct class name and dll location?"

use task dialog in your code to show some messages to check whether your addin is working fine or not!!!

If the taskdialog doesn't appear then the problem may be with your addin file.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

Anonymous
Not applicable

Hi @naveen.kumar.t ,

Thank for your reply,

 

I try add task dialog in my code that work correctly, My code and results figure as following :

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            try
            {
                RevitCommandId cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.SolidExtrusion);
                uiapp.PostCommand(cmdId);

            }
            catch (Exception e)
            {
            }

            TaskDialog.Show("Test", "Hello");
            return Result.Succeeded;
        }

 

hello.png

 

And, I tried another command like Default3DView that can correctly change view form plane to 3D-view

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            RevitCommandId cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.Default3DView);
            uiapp.PostCommand(cmdId);
            return Result.Succeeded;
        }

thank you

 

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @Anonymous ,

 It is very strange.

make sure  "revitCommanID" is not null.

My suggestion is to close the current visual studio project and try the same code in the new visual studio project.

See whether it works or not!!!!!

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

Anonymous
Not applicable

Hi @naveen.kumar.t 

I used another computer create new visual studio project to do and it not works too,

In the debug mode, the revitCommanID is not null,

full.png

 

Thank you

0 Likes

Revitalizer
Advisor
Advisor

Hi,

 

what is the result of uiapp.CanPostCommand(cmdId) ?

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes

Anonymous
Not applicable

Hi @Revitalizer 

 

The result is true.

ff.png

0 Likes

Revitalizer
Advisor
Advisor

Hi,

 

that's a joke, isn't it?

 

You tested it with Default3DView but the error occured when calling SolidExtrusion...

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes

Revitalizer
Advisor
Advisor

Hi,

check if you can post a command before you post it.

 

RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.SolidExtrusion);

if (uiapp.CanPostCommand(commandId))
{
	uiapp.PostCommand(commandId);
}

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes

Anonymous
Not applicable

hi @Revitalizer 

I'm so sorry, I forgot change back to Solid Extrusion..

The result is true too.

thank you

f2.png

 

0 Likes

Revitalizer
Advisor
Advisor

Hi,

 

seems to be a bug in the API.

 

But if you just want to create an Extrusion in the family document, why not using familyDoc.FamilyCreate.NewExtrusion method?

 

Get the curves (CurveElement.GeometryCurve) of the selected Elements, get or create a proper SketchPlane, define your extrusion thickness, and you are done.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes

Anonymous
Not applicable

Hi @Revitalizer 

Thanks for your suggest, 

 

In my case,  I want to form Solid by defined profile beforehand, that profile define in another families document and  insert to Mainly Family document, 

 

In Mainly Family document, I used familyDoc.FamilyCreate.NewFamilyInstance create profile FamilyInstance, and used FamilyCreate.NewExtrusion to form solid.

 

But the FamilyCreate.NewExtrusion input seem only for ModelCurve, can't use FamilyInstance directly,

So that I need transfer FamilyInstance to Modelcurves to generate.

 

Above, I have achieved, but few days ago, I find the command "SolidExtrusion" , So I just try it,

If it can works, that will convenient very much.

 

Thank you.

 

 

 

 

 

0 Likes

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

if you create a Sweep instead of an Extrusion, you can hand over a FamilySymbol for the profile to use.

SweepProfile profile = uiApp.Application.Create.NewFamilySymbolProfile(profileFamilySymbol);
Sweep sweep = famDoc.FamilyCreate.NewSweep(true, path, sketchPlane, profile, 0, ProfilePlaneLocation.Start);

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes

Anonymous
Not applicable

hi @Revitalizer 

Thank you, I will try it,

0 Likes