- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How can I use the 'Project Objects To Profile View' command using the Civil 3D API, with C#, to project a selected Solid3d to the selected Profile View from a Modeless Dialog?
The API does not support this call, I followed this https://forums.autodesk.com/t5/net/how-can-i-use-project-objects-to-profile-view-with-c/td-p/1287474... topic to use the Editor.Command();
However, when I try to call this command from the Modeless Dialog, I get an 'Invalid input' exception.
My command uses this flag:
[CommandMethod("DoProjectToProfileView", CommandFlags.UsePickSet)]
This is the relevant code:
// clear the pickfirst set
_ed.SetImpliedSelection(new ObjectId[0]);
// create selection sets
ObjectId[] solidIds = { selectedSolidId };
ObjectId[] profViewIds = { _selectedProfileViewId };
var solidSelectionSet = SelectionSet.FromObjectIds(solidIds);
var profileSelectionSet = SelectionSet.FromObjectIds(profViewIds);
// project
_ed.Command("_.AECCPROJECTOBJECTSTOPROF", solidSelectionSet, "", profileSelectionSet, "");
I tried to surround the Editor.Command with using (_doc.LockDocument()), same as when calling transactions from the Modeless dialog, but it does not help, same exception shows.
If I Close(); the dialog and then try to do the above code, I again get the same exception.
I tried to use the dynamic variable, and got half a result. I can successfully run the command, but cannot set the selection sets.
dynamic doc = _doc.GetAcadDocument();
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r");
// this works as well:
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF ");
// but none of these do!
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, "", profileSelectionSet);
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, "", profileSelectionSet, "");
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, "\r", profileSelectionSet);
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, "\r", profileSelectionSet, "");
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, " ", profileSelectionSet);
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, " ", profileSelectionSet, "");
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, "\r", profileSelectionSet, "\r");
doc.SendCommand("_.AECCPROJECTOBJECTSTOPROF\r", solidSelectionSet, " ", profileSelectionSet, " ");
What else could I try, or do not understand? Calling the C3D commands is always a heavy guesswork for me, on trying to replicate the C3D workflow.
Solved! Go to Solution.