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

AutoCAD Library Or Block

12 REPLIES 12
Reply
Message 1 of 13
santoshr0114
1496 Views, 12 Replies

AutoCAD Library Or Block

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
Tags (2)
12 REPLIES 12
Message 2 of 13

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 13

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
Message 4 of 13

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.

😉   🙂

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 13

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
Message 6 of 13

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 13
santoshr0114
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
Message 8 of 13

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 9 of 13

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
Message 10 of 13

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 11 of 13

Hi,

 

I can create and add the block reference programatically sucessfully.

 

Now i am not creating, but only adding a block reference with the existing block reference by refering it with its blockname. The problem is when i try to add an existing block reference to new locaiton to the same drawing file where the block is present.

 

Check the code, i am not not creating a block reference.

 

The Block Name created is "Dummy", I am trying to add the same block in different location.

 

I cannot stop the execution in between as i have added the output source to AutoCAD Application. If i stop then AutoCAD also closes.

 

Thank You

Regards
Santosh
Message 12 of 13

Hi,

 

>> I cannot stop the execution in between as i have added the output source to AutoCAD Application

Maybe I don't understand that, ... Just set a breakpoint at the first line within your command-code for "ADD_Block". It has to stop at the breakpoint. If VS does not you have any other problem (additionally to the block-insert).

 

And one sentence to this line:

bt[blockName]

By default it returns an ObjectID from the BlockTableRecord with the name <blockName>. But it's critical as it returns the FIRST occurence of a BlockTableRecord for this name. Imagine you have created a blockdefinition (so a BlockTableRecord is created) .... then you do a _PURGE ==> the BlockTableRecord is not removed from the database, it exists there as long as the drawing is not closed, the BlockTableRecord is just marked as deletet.

The result is: the next time you create a BlockTableRecord with the same name you got two BlockTableRecords each pointing to the same blockname, but the first one has the property .IsErased = TRUE and the new one has this set to FALSE.

With your code you just search for the first BlockTableRecord for name "blockName" and then you use it for insert ... EVEN IF IT's ERASED in the meantime ..... ever checked for the property .IsErased? If not ..,. do it 😉

 

Hope that is clear to understand!

 

-. alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 13 of 13

Hi,

 

Ok WIll Try doing so..

 

Thank You for your time

 

Will let you know if there are more updates on this

Regards
Santosh

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