Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PostCommand do not have reaction

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
Anonymous
813 Views, 13 Replies

PostCommand do not have reaction

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

 

 

 

 

13 REPLIES 13
Message 2 of 14
naveen.kumar.t
in reply to: Anonymous

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

Message 3 of 14
Anonymous
in reply to: naveen.kumar.t

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

 

Message 4 of 14
naveen.kumar.t
in reply to: Anonymous

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

Message 5 of 14
Anonymous
in reply to: naveen.kumar.t

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

Message 6 of 14
Revitalizer
in reply to: Anonymous

Hi,

 

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

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 14
Anonymous
in reply to: Revitalizer

Hi @Revitalizer 

 

The result is true.

ff.png

Message 8 of 14
Revitalizer
in reply to: Anonymous

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





Message 9 of 14
Revitalizer
in reply to: Anonymous

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





Message 10 of 14
Anonymous
in reply to: Revitalizer

hi @Revitalizer 

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

The result is true too.

thank you

f2.png

 

Message 11 of 14
Revitalizer
in reply to: Anonymous

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





Message 12 of 14
Anonymous
in reply to: Revitalizer

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.

 

 

 

 

 

Message 13 of 14
Revitalizer
in reply to: Anonymous

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





Message 14 of 14
Anonymous
in reply to: Revitalizer

hi @Revitalizer 

Thank you, I will try it,

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report