Hi.
I want to do Solid Extrusion by Post command, My step is following :
1. Create a profile in Revit Family Document
2. Select the profile
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
Solved! Go to Solution.
Solved by Revitalizer. Go to Solution.
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.
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; }
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
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!!!!!
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,
Thank you
Hi,
what is the result of uiapp.CanPostCommand(cmdId) ?
Revitalizer
Hi,
that's a joke, isn't it?
You tested it with Default3DView but the error occured when calling SolidExtrusion...
Revitalizer
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
hi @Revitalizer
I'm so sorry, I forgot change back to Solid Extrusion..
The result is true too.
thank you
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
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.
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
Can't find what you're looking for? Ask the community or share your knowledge.