.NET

Reply
Mentor
santoshr0114
Posts: 161
Registered: ‎03-21-2012
Message 1 of 13 (848 Views)

AutoCAD Library Or Block

848 Views, 12 Replies
07-03-2012 01:47 AM

Hi Guys,

 

I have a Block (just assume any unusual shape converted to a block), and i need to use the same block in many other drawings.

 

I dont want to copy or add the block from another drawing.

 

I want the block to be a part of AutoCAD library, whenever the AutoCAD loads the option to insert that block should be available.

 

Even if i can add it as a object in the Ribbon under Draw where all other gemetry shapes(Line, Polyline, Rectangle, etc) are available, then it would be very useful.

 

But not getting an idea to how to do that or where to begin with . . . ! ! !

 

How can i do that.???

 

Awaiting Reply.....!!

Regards
Santosh
*Expert Elite*
Alfred.NESWADBA
Posts: 8,893
Registered: ‎06-29-2007
Message 2 of 13 (846 Views)

Re: AutoCAD Library Or Block

07-03-2012 02:00 AM in reply to: santoshr0114

Hi,

 

>> I want the block to be a part of AutoCAD library

There does not exist any "AutoCAD library", so what do you mean by that?

If you want to have a list of symbols to be used then create a folder, copy your block-dwg's to this folder and add this path to the support-paths within AutoCAD-options.

 

>> I dont want to copy or add the block from another drawing.

You can also define the block in your template, so you have it defined within every new drawing that is created based on that template.

But for existing drawings you need to insert the definition once when you want to have the block-definition within this drawing. There is no magic "automatically insert all blockdefinitions in all drawings on my harddisk and my server" .... as long as you don't write such an app. (But imho makes no sense to fill non-used data into every dwg).

 

>> I dont want to copy or add the block from another drawing.

To us a block from the toolpalette ==> just open a drawing where this block is defined and inserted in e.g. model-space. Than take it and drag it to the toolpalette. That's all.

 

>> Awaiting Reply.....!!

I call that friendly ;(

No word like "please" or anything like that, but "awaiting" .... do you know that none of the people here (except those from Autodesk) do get money for helping people like you?

 

Last but not least ... what have your questions to do with .NET-development (the forum where you placed this thread)?

That are AutoCAD-basic questions, nothing points to development-issues ... or don't I see that?

 

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
santoshr0114
Posts: 161
Registered: ‎03-21-2012
Message 3 of 13 (843 Views)

Re: AutoCAD Library Or Block

07-03-2012 03:00 AM in reply to: Alfred.NESWADBA

Hi Alfred.Neswadba,

 

I have posted this in Autocad .Net Customization as i want to do this task programatically.

 

As you said I can add the blocks in a directory and use it everytime i need it.

 

But i need to create a User Interface(Button/Command/Pallete Component) using .Net(C# or VB) which when clicked gives a user option to add those objects in his Model Space. 

 

If i am not clear let me know will try to elaborate.

 

And as you mentioned....

 

Thank You& Please provide a solution if you know.

Regards
Santosh
*Expert Elite*
Alfred.NESWADBA
Posts: 8,893
Registered: ‎06-29-2007
Message 4 of 13 (840 Views)

Re: AutoCAD Library Or Block

07-03-2012 03:06 AM in reply to: santoshr0114

Hi,

 

to insert a blockreference there are so much samples out  >>>there<<< .... or I don't understand the question, then sorry.

 

>> Thank You& Please provide a solution if you know.

:smileywink:   :smileyhappy:

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
santoshr0114
Posts: 161
Registered: ‎03-21-2012
Message 5 of 13 (839 Views)

Re: AutoCAD Library Or Block

07-03-2012 03:14 AM in reply to: Alfred.NESWADBA

Hello,

 

Yes you are right...

 

i have used http://adndevblog.typepad.com/autocad/2012/06/inserting-a-block-with-attributes-to-modelspace.html as a reference. But my AutoCAD application crashes.

 

If i create my own block and then insert it then then there is no problem. I have used the below link as reference for creating and inserting

http://through-the-interface.typepad.com/through_the_interface/2010/01/creating-an-autocad-block-usi...

 

Thank You

Regards
Santosh
*Expert Elite*
Alfred.NESWADBA
Posts: 8,893
Registered: ‎06-29-2007
Message 6 of 13 (835 Views)

Re: AutoCAD Library Or Block

07-03-2012 03:17 AM in reply to: santoshr0114

Hi,

 

>> But my AutoCAD application crashes.

You have an error message or screenshot so we know a little bit more about "how AutoCAD crashes"

When you run the code in debug-mode (assuming that you set to stop at all errors during debug) does VS not stop at any code-line?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
santoshr0114
Posts: 161
Registered: ‎03-21-2012
Message 7 of 13 (834 Views)

Re: AutoCAD Library Or Block

07-03-2012 03:23 AM in reply to: santoshr0114

Hi,

 

There is no error, i have used breakpoints and checked the code in debug mode The Application just crashes. I have attached the screen shot of the window appearing after the application crash.

 

 

 

 

My objective is to create a command which inserts a object into the model space and allows user to modify it in size.

This object should load With AutoCAD application as a Addin loads with Autodesk Inventor.

 

For Example:

 

The outer design of a mobile phone. The default shape doesn't vary for most of the smart phones only the size does. I have to create a command "Mobile" which when executed should place the mobile outer design on the model space on the desired location, and only allow the user to change the dimension.

 

Similar to the function performed when you enter the command "Circle" and click on the model space a circle drawn.

 

I hope i made myself clear now...

 

Thank You

Regards
Santosh
*Expert Elite*
Alfred.NESWADBA
Posts: 8,893
Registered: ‎06-29-2007
Message 8 of 13 (825 Views)

Re: AutoCAD Library Or Block

07-03-2012 03:53 AM in reply to: santoshr0114

Hi,

 

>> My objective is to create a command which inserts a object into the model space

>> and allows user to modify it in size

OK; the error message tells not as much as I hoped. But I wonder that the debugger does not stop when the exception occurs. Have you really tried to run in debug-mode? What happens if you place a breakpoint and step through your code line-by-line?

BTW: can you show the code at the state you have now?

 

Another idea before you do a lot of work with jigging: does your code do anything else after positioning and scaling the blockreference? If not I would try as alternative to use SendStringToExecute and send a simple insert-command (or enclosed in a lisp-function) then. E.g. this one:

_INSERT<ENTER>

yourBlockName<ENTER>

 

At least worth to try. It's good to verify that your block-definition does not have created defects in the database (without letting you know that) and when the code reaches the position where to insert now the block as reference it comes up with the defect then.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
santoshr0114
Posts: 161
Registered: ‎03-21-2012
Message 9 of 13 (824 Views)

Re: AutoCAD Library Or Block

07-03-2012 04:02 AM in reply to: Alfred.NESWADBA

Hi,

 

I have used the same code as given in the link

 

And the debugger doesnot stop at all untill the execution is over.

I have also attached the code in  .txt format.

 

Thank YOU

Regards
Santosh
*Expert Elite*
Alfred.NESWADBA
Posts: 8,893
Registered: ‎06-29-2007
Message 10 of 13 (822 Views)

Re: AutoCAD Library Or Block

07-03-2012 04:16 AM in reply to: santoshr0114

Hi,

 

>> I have used the same code as given in [...]

>> And the debugger doesnot stop at all untill the execution is over.

Makes me more than ever thinking that the block-creation has then created defects in the database.

Try my suggestion above to create the blockreference by sending the command using SendStringToExecute (just now for dedication).

What you also can try: after your code run the creation of the blockdefinition ==> stop the code and run command _AUDIT. Does AutoCAD then crash?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community