disable Current view only in Link CAD command

disable Current view only in Link CAD command

Ning_Zhou
Advocate Advocate
6,351 Views
8 Replies
Message 1 of 9

disable Current view only in Link CAD command

Ning_Zhou
Advocate
Advocate

is it possible? seems only main command can be disabled like Import CAD, Link CAD, etc.

0 Likes
Accepted solutions (1)
6,352 Views
8 Replies
Replies (8)
Message 2 of 9

jeremytammik
Autodesk
Autodesk

Dear Ning,

 

Thank you for your query.

 

Please try out the BaseImportOptions.ThisViewOnly property and let us know how it goes.

 

I hope this helps.

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 9

Ning_Zhou
Advocate
Advocate

thanks Jeremy for your suggestion.

 

seems i cannot initialize BaseImportOptions so i tried DWGImportOptions for both Executed and CanExecute events

1) Executed event will disable main command no matter what options i use

2) CanExecute event have no effect at all, means setting DWGImportOptions.ThisViewOnly to false won't grey out that option

 

maybe i missed something!?

0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Dear Ning,

 

This sounds like something is going wrong.

 

Please provide a minimal reproducible case so I can pass the issue on to the development team for further exploration:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

Cheers,

 

Jeremy



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

0 Likes
Message 5 of 9

Ning_Zhou
Advocate
Advocate

since i directly used DisableCommand from SDK sample, just a few lines added / modified, so i post these addition / modification here for your info., let me know if you still need whole solution files.

 

// commandBinding.Executed += DisableEvent; // original

commandBinding.CanExecute += commandBinding_CanExecute; // event added

 

void commandBinding_CanExecute(object sender, CanExecuteEventArgs e)

{

 DWGImportOptions io = new DWGImportOptions();

 io.ThisViewOnly = false;

}

 

static String s_commandToDisable = "ID_FILE_CADFORMAT_LINK"; // link CAD

0 Likes
Message 6 of 9

jeremytammik
Autodesk
Autodesk

Dear Ning,

 

Thank you for the update.

 

You can use the {i} Insert Code button to make your source code more readable.

 

The development team respond to your update and say:

 

This looks very strange.  What is the user hoping to accomplish?    To force the UI option to change?   That is not what the options are for – they are in place to be passed to the Import or Link functions so that the API can accomplish the operation.   They are not tied to settings in the dialog at the dialog level where changing one would affect the other.

 

Can you explain, please?

 

Thank you!

 

Cheers,

 

Jeremy



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

0 Likes
Message 7 of 9

Ning_Zhou
Advocate
Advocate

thanks Jeremy for your reply.

 

yes, indeed i want to force UI to change, disable that Current View Only option, in standard UI when in 3D view that option is greyed out, that's the effect i want to achieve.

 

why do i want this effect you may ask, well, i want to avoid duplicates of linked CAD, when using Current View Only option, users will link same CAD multiple times in different views, i'm sure it's going to cause Revit performance issue along w/ model quality problem, isn't it? so what i think and want to do is only allow users use link CAD w/o Current View Only option, basically get rid of CAD completely except for temporarily reference only.

0 Likes
Message 8 of 9

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Ning,

 

Thank you for the explanation.

 

Have you made any further progress on this since then?

 

Here is some further discussion back and forth among the development team members:

 

[A] That's an interesting request.

 

I would say, there is a value in an ability to enforce common modelling practices. MicroStation has always had the option of locking out certain tools (but not tool options, AFAIR). That was often mentioned as a very productive feature by the CAD managers. Perhaps we could file that as a long-term request.

 

Jeremy – perhaps Ning could use the FindImports tool you blogged about a while ago. That will let him search the projects for duplicate imports.

 

[B] I believe you can programmatically replace an entire command, just not part of it. You can disable a command via addon by replacing the UI with "don't do this." Of course it could be better.

 

[C] You are right: we have the ability to replace a command, or add new validation for when it is active or inactive in the UI.

 

In theory, they could implement a replacement streamlined Import CAD command that doesn't have the option. (In Kepler, this could even use the Revit file dialogs – in earlier versions, they would have to use a Windows file dialog instead). The options would not live in the File Dialog either way, of course. I'm not saying this is necessarily a good idea, but I think we have all the options exposed so it would be feasible.

 

[D] That, developed into a (reasonably) user-friendly tool, might be well received by larger customers.

 

Does this provide any new insight for you?

 

Do you have any further input on this?

 

Thank you!

 

Cheers,

 

Jeremy



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

Message 9 of 9

Ning_Zhou
Advocate
Advocate
thanks Jeremy & development team members for your in-depth explanation. this confirms my guess that ONLY entire command can be replaced, just not part of it. workaround will be using own dialog to replace OOTB one for options, should work as long as all options are API-accessible, i'll try that later. very appreciated for your help.
0 Likes