.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autocad commands not executing in time.

13 REPLIES 13
Reply
Message 1 of 14
jithin.dcs
610 Views, 13 Replies

Autocad commands not executing in time.

I have a c# application. If i net load it in autocad it will show a modal dialog. If i press a button in that form, it should hide and it should open a dwg file in autocad. and after opening i wrote the code to show another modal dialog.

My problem is if i click the button it will directly show the second form without opening the dwg file. It will open only if i close the second form.
Autocad commands is not executing in time. Can anyone suggest what may be the problem?

// commands.cs file

// This is how i am opening the dwg file
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(filename, false);

// Here i am opening the second form.
objCreate = new CreateTemplate(std, filename, "Edit");
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(objCreate);

thanks in advance

Jithin Edited by: jithin.dcs on Nov 30, 2009 8:58 AM
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: jithin.dcs

Sorry, this isn't really enough code to diagnose the problem.

In cases like this, the calling context is very relevant, all the
way back to the command the user issues to start the dialog.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6296332@discussion.autodesk.com...
I have a c# application. If i net load it in autocad it will show a modal
dialog. If i press a button in that form, it should hide and it should open
a dwg file in autocad. and after opening i wrote the code to show another
modal dialog.

My problem is if i click the button it will directly show the second form
without opening the dwg file. It will open only if i close the second form.
Autocad commands is not executing in time. Can anyone suggest what may be
the problem?

// commands.cs file

// This is how i am opening the dwg file
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
=
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(filename,
false);

// Here i am opening the second form.
objCreate = new CreateTemplate(std, filename, "Edit");
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(objCreate);

thanks in advance

Jithin

Edited by: jithin.dcs on Nov 30, 2009 8:58 AM
Message 3 of 14
jithin.dcs
in reply to: jithin.dcs

hi,

thanks for your reply.. here is the code

// Button click
private void btnEditTemplate_Click(object sender, EventArgs e)
{
// Hiding the first modal dialog
this.Hide();

// Function call to open the dwg file and show the second modal dialog (this function is in commands.cs file)
Commands.ShowTemplateEdit(filename, tvTemplates.SelectedNode.Parent.Text);
}

// Function in commands.cs
// Function to show the drawing and edit template window (Only for edit)
static public void ShowTemplateEdit(string filename,string std)
{
// Declaring the second form object
CreateTemplate objCreate;

Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

filenameforOpen = filename;

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(filename, false);

objCreate = new CreateTemplate(std, filename, "Edit");
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(objCreate);
} Edited by: jithin.dcs on Nov 30, 2009 10:31 AM
Message 4 of 14
Anonymous
in reply to: jithin.dcs

The only way I think you can do this, is to have the code that displays the
dialog (e.g., calls Application.ShowModalDialog()) open the file, after the
call to the latter returns.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6296370@discussion.autodesk.com...
hi,

thanks for your reply.. here is the code

// Button click
private void btnEditTemplate_Click(object sender, EventArgs e)
{
// Hiding the first modal dialog
this.Hide();

// Function call to open the dwg file and show the second modal dialog
(this function is in commands.cs file)
Commands.ShowTemplateEdit(filename,
tvTemplates.SelectedNode.Parent.Text);
}

// Function in commands.cs
// Function to show the drawing and edit template window (Only for edit)
static public void ShowTemplateEdit(string filename,string std)
{
// Declaring the second form object
CreateTemplate objCreate;

Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

filenameforOpen = filename;

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
=
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(filename,
false);

objCreate = new CreateTemplate(std, filename, "Edit");
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(objCreate);
}

Edited by: jithin.dcs on Nov 30, 2009 10:31 AM
Message 5 of 14
jithin.dcs
in reply to: jithin.dcs

hi,

thanks for your reply

i have tried that also. I called show modal dialog and after showing the form i returned some value and then i tried to open file. The same thing happened here also. It showed the form only and not opened the file. If i close the form, then at that moment the file opens.. Actually i need to show some xdata information to the form from the opened file. So if this works also that will not help me..

any other suggestions...?
Message 6 of 14
Anonymous
in reply to: jithin.dcs

You don't show the CommandMethod that starts everything, and what
CommandFlags it uses.

Does it use CommandFlags.Session ?

If so, there should be no problem opening a file after the call to
ShowModalDialog() returns.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6297749@discussion.autodesk.com...
hi,

thanks for your reply

i have tried that also. I called show modal dialog and after showing the
form i returned some value and then i tried to open file. The same thing
happened here also. It showed the form only and not opened the file. If i
close the form, then at that moment the file opens.. Actually i need to show
some xdata information to the form from the opened file. So if this works
also that will not help me..

any other suggestions...?
Message 7 of 14
jithin.dcs
in reply to: jithin.dcs

i dont want to open file after modal dialog shows. I want to open file first and then display the modal dialog. so that i can read xrecords from drawing and show it in modal dialog.
Message 8 of 14
Anonymous
in reply to: jithin.dcs

You still haven't answered the question about your command and whether it
runs in the application context or the document context.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6297866@discussion.autodesk.com...
i dont want to open file after modal dialog shows. I want to open file first
and then display the modal dialog. so that i can read xrecords from drawing
and show it in modal dialog.
Message 9 of 14
jithin.dcs
in reply to: jithin.dcs

i am calling a function in the commands.cs file from the modal dialog's button click. This function (in commands.cs file) will open a drawing and then it should show the second modal dialog. So in the document context only i am doing both the things..
Message 10 of 14

hi

i m also facing the same problem

i prompt the user to select a starting point
after selecting a point i will show a dialogbox which contains two buttons continue and End
if user clicks on conitnue then i prompt the user to select the another point
now i will pass these two points to a lisp command (by loading the lisp file and send these values)

then a drawing is generated

after drawing is generated i show the dialogbox whether to continue or end

if user selects continue then the same process is repeated

please help me
Message 11 of 14
Anonymous
in reply to: jithin.dcs

I can't really help further without seeing the declaration of the method
with the CommandMethod attribute.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6298484@discussion.autodesk.com...
i am calling a function in the commands.cs file from the modal dialog's
button click. This function (in commands.cs file) will open a drawing and
then it should show the second modal dialog. So in the document context
only i am doing both the things..
Message 12 of 14
jithin.dcs
in reply to: jithin.dcs

hi,

i solved the problem. as u said earlier, i used commandflags.session and inside the method i wrote code for both file open and show modal. then it worked properly.

thank you very much for your support

Jithin Shyam
Message 13 of 14

hi
i too facing with the same problem

but with a small difference , u r opening a dwg file
but i m executing a lispfunction

if u dont mind please can u tell me how you solved your problem
with a sample code


thanks in advance

vijay kumar
Message 14 of 14
jithin.dcs
in reply to: jithin.dcs

hi vijay,

I wrote code for opening a drawing as well as calling modal dialog show in the same command method and it has parameter command flags as session.

for example

[CommandMethod("OpenDwg",CommandFlags.Session)]
static public void OpenDwg()
{
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(filenameforOpen, false);

objcreate = new CreateTemplate(selectedStd, filenameforOpen, "Edit");
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(objcreate);
}
}

thanks

Jithin Shyam S

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost