PDA

View Full Version : Externally setting a block of text in AutoCAD


Michael Heumann
11-09-2004, 02:17 PM
Hi,
I have never worked with AutoCAD, but now a client needs me to develop
an application that involves handling DWG files. What I need to do is
open AutoCAD with some kind of template file and automatically set its
label (which I understand is just a block of several text fields) to
content provided outside.
My question is: What is the smartest (and easiest) way of doing this?
I understand AutoCAD has OLE Automation features. Can I manipulate a
drawing from an external application through OLE? Another option
might be AutoLISP. How could that work for me?
I would really appreciate any helpful hint from someone who handles
the programming aspect of AutoCAD rather than "just" the user's
perspective.
I've only been provided a standard user manual of AutoCAD (by the way,
the version is 2000i), but that doesn't seem to cover these advanced
features.
Thanks,
Michael.

Michael Bulatovich
11-09-2004, 02:35 PM
You are asking a tall pile of questions, Michael,
while giving only a rough sketch of the context.
Better get familiar with the application a bit,
check in the online Help under Customization,
then come back to the group when you've got
something put together.
I don't know OLE at all but what you want may be
possible through LISP and a script. You have to
get way more specific.
--


MichaelB
www.michaelbulatovich.com

"Michael Heumann" <mheumann@gmx.net> wrote in message
news:a817b20.0411091417.225e8bfb@posting.google.com... Hi, I have never worked with AutoCAD, but now a client needs me to develop an application that involves handling DWG files. What I need to do is open AutoCAD with some kind of template file and automatically set its label (which I understand is just a block of several text fields) to content provided outside. My question is: What is the smartest (and easiest) way of doing this? I understand AutoCAD has OLE Automation features. Can I manipulate a drawing from an external application through OLE? Another option might be AutoLISP. How could that work for me? I would really appreciate any helpful hint from someone who handles the programming aspect of AutoCAD rather than "just" the user's perspective. I've only been provided a standard user manual of AutoCAD (by the way, the version is 2000i), but that doesn't seem to cover these advanced features. Thanks, Michael.

Cadalot
11-09-2004, 10:16 PM
Mike

OLE is Object Link and Embedment, where you might
copy a section of a word docymnet or excell document.
It a Windows function

Sounds like he wants to fill in a drawing title block that
has been created as a block with attributes from an
external source.....

I suggest he looks at blocks and attributes and then
passing information form and two the drawing from
an external source via LISP.

I wrote an application for a company that did this to
create a bill of materials taking information from basic
symbols with attributes. The reversed engineered it so that
they could run a lisp to create a drawing based on a
TXT or CSV file of information

Alan

On Tue, 9 Nov 2004 17:35:24 -0500, "Michael Bulatovich"
<Please@dont.try> wrote:
You are asking a tall pile of questions, Michael,while giving only a rough sketch of the context.Better get familiar with the application a bit,check in the online Help under Customization,then come back to the group when you've gotsomething put together.I don't know OLE at all but what you want may bepossible through LISP and a script. You have toget way more specific.

Michael Bulatovich
11-10-2004, 05:40 AM
I've got my own guess as to what he wants too, Alan, it
closely matches yours. However he may also want other
stuff, or something else. It sounds like he hasn't got to
recognizing entity types yet, hence my comment.
If that's so, it's a long road.....

"Cadalot" <alan@killspam.co.uk> wrote in message
news:n7c3p0137ft7cm9q843v5oaaj2vhlaqju8@4ax.com... Mike OLE is Object Link and Embedment, where you might copy a section of a word docymnet or excell document. It a Windows function Sounds like he wants to fill in a drawing title block that has been created as a block with attributes from an external source..... I suggest he looks at blocks and attributes and then passing information form and two the drawing from an external source via LISP. I wrote an application for a company that did this to create a bill of materials taking information from basic symbols with attributes. The reversed engineered it so that they could run a lisp to create a drawing based on a TXT or CSV file of information Alan On Tue, 9 Nov 2004 17:35:24 -0500, "Michael Bulatovich" <Please@dont.try> wrote:You are asking a tall pile of questions, Michael,while giving only a rough sketch of the context.Better get familiar with the application a bit,check in the online Help under Customization,then come back to the group when you've gotsomething put together.I don't know OLE at all but what you want may bepossible through LISP and a script. You have toget way more specific.

Michael Heumann
11-24-2004, 03:28 PM
First of all, thanks, Michael and Cadalot for your attempts at aiding
me, in spite of my obvious cluelessness.
In the meantime, I've advanced somewhat on the topic, so I think I can
try to be a little more specific with my request.

I have a drawing that contains several annotation objects (text
entities?) which are grouped together in a block. Together they
represent a label that is supposed to hold detailed information about
the drawing, such as title, author, codes of all sorts etc.

What I need to do is to programmatically set the values for these text
objects. It would really help if any of you could tell me which
AutoLISP instructions I need to access that block and the text objects
within.

Thanks for your help.
Greetings,
Michael.


"Michael Bulatovich" <Please@dont.try> wrote in message news:<HXokd.20437$Z7.715183@news20.bellglobal.com>... I've got my own guess as to what he wants too, Alan, it closely matches yours. However he may also want other stuff, or something else. It sounds like he hasn't got to recognizing entity types yet, hence my comment. If that's so, it's a long road..... "Cadalot" <alan@killspam.co.uk> wrote in message news:n7c3p0137ft7cm9q843v5oaaj2vhlaqju8@4ax.com... Mike OLE is Object Link and Embedment, where you might copy a section of a word docymnet or excell document. It a Windows function Sounds like he wants to fill in a drawing title block that has been created as a block with attributes from an external source..... I suggest he looks at blocks and attributes and then passing information form and two the drawing from an external source via LISP. I wrote an application for a company that did this to create a bill of materials taking information from basic symbols with attributes. The reversed engineered it so that they could run a lisp to create a drawing based on a TXT or CSV file of information Alan On Tue, 9 Nov 2004 17:35:24 -0500, "Michael Bulatovich" <Please@dont.try> wrote:You are asking a tall pile of questions, Michael,while giving only a rough sketch of the context.Better get familiar with the application a bit,check in the online Help under Customization,then come back to the group when you've gotsomething put together.I don't know OLE at all but what you want may bepossible through LISP and a script. You have toget way more specific.

Michael Bulatovich
11-24-2004, 03:54 PM
There are two ways that text entities can be in a block:

1) Plain old MTEXT or TEXT
2) Attributes

You access these differently. It sounds like you are trying to
edit a title block. Many people use title blocks containing ATTRIBUTES,
though
some people like to split up the ATTRIBUTES in a separate BLOCK,
and leave the other linework, logos, etc in another BLOCK.

Enter the following at the command prompt in a drawing with one of your
title blocks:

(entget(car(entsel)))

then hit enter and pick the titleblock. What do you see?
--


MichaelB
www.michaelbulatovich.com



MichaelB
www.michaelbulatovich.com

"Michael Heumann" <mheumann@gmx.net> wrote in message
news:a817b20.0411241528.625e1b40@posting.google.com... First of all, thanks, Michael and Cadalot for your attempts at aiding me, in spite of my obvious cluelessness. In the meantime, I've advanced somewhat on the topic, so I think I can try to be a little more specific with my request. I have a drawing that contains several annotation objects (text entities?) which are grouped together in a block. Together they represent a label that is supposed to hold detailed information about the drawing, such as title, author, codes of all sorts etc. What I need to do is to programmatically set the values for these text objects. It would really help if any of you could tell me which AutoLISP instructions I need to access that block and the text objects within. Thanks for your help. Greetings, Michael. "Michael Bulatovich" <Please@dont.try> wrote in message
news:<HXokd.20437$Z7.715183@news20.bellglobal.com>... I've got my own guess as to what he wants too, Alan, it closely matches yours. However he may also want other stuff, or something else. It sounds like he hasn't got to recognizing entity types yet, hence my comment. If that's so, it's a long road..... "Cadalot" <alan@killspam.co.uk> wrote in message news:n7c3p0137ft7cm9q843v5oaaj2vhlaqju8@4ax.com... Mike OLE is Object Link and Embedment, where you might copy a section of a word docymnet or excell document. It a Windows function Sounds like he wants to fill in a drawing title block that has been created as a block with attributes from an external source..... I suggest he looks at blocks and attributes and then passing information form and two the drawing from an external source via LISP. I wrote an application for a company that did this to create a bill of materials taking information from basic symbols with attributes. The reversed engineered it so that they could run a lisp to create a drawing based on a TXT or CSV file of information Alan On Tue, 9 Nov 2004 17:35:24 -0500, "Michael Bulatovich" <Please@dont.try> wrote: >You are asking a tall pile of questions, Michael, >while giving only a rough sketch of the context. >Better get familiar with the application a bit, >check in the online Help under Customization, >then come back to the group when you've got >something put together. >I don't know OLE at all but what you want may be >possible through LISP and a script. You have to >get way more specific.

Michael Heumann
11-25-2004, 08:39 AM
According to what I was told by the people who made the file, the
block consists of Attributes.

Here's the output of what you requested:

Command: (entget(car(entsel)))
Select object: ((-1 . <Entity name: 259a4a8>) (0 . "INSERT") (330 .
<Entity
name: 259ac10>) (5 . "78D") (100 . "AcDbEntity") (67 . 0) (410 .
"Model") (8 .
"1") (100 . "AcDbBlockReference") (66 . 1) (2 . "ROT1") (10 20900.0
125.0 0.0)
(41 . 25.0) (42 . 25.0) (43 . 25.0) (50 . 0.0) (70 . 0) (71 . 0) (44 .
0.0) (45
.. 0.0) (210 0.0 0.0 1.0))

"ROT1" is the name of the block, so I assume I did it correctly.
Otherwise, the above honestly doesn't tell me much.
I could provide a sample file if that's helpful.

Thanks,
Michael.



"Michael Bulatovich" <Please@dont.try> wrote in message news:<id9pd.37670$Ro.1562379@news20.bellglobal.com>... There are two ways that text entities can be in a block: 1) Plain old MTEXT or TEXT 2) Attributes You access these differently. It sounds like you are trying to edit a title block. Many people use title blocks containing ATTRIBUTES, though some people like to split up the ATTRIBUTES in a separate BLOCK, and leave the other linework, logos, etc in another BLOCK. Enter the following at the command prompt in a drawing with one of your title blocks: (entget(car(entsel))) then hit enter and pick the titleblock. What do you see? -- MichaelB www.michaelbulatovich.com

Michael Bulatovich
11-25-2004, 09:05 AM
There are a couple of routines on my site that access and manipulate
attributes.
You could examine them and you should be able you figure out how to
access yours through lisp. I right fairly clunky but easy to follow
code, and I annotate it quite a bit to keep it straight in my own mind.
You are welcome to them.

The basic trick to getting at attributes is that you have to look for the
*next* item in the database after the block that contains them.
--


MichaelB
www.michaelbulatovich.com

"Michael Heumann" <mheumann@gmx.net> wrote in message
news:a817b20.0411250839.2bf5cf02@posting.google.com... According to what I was told by the people who made the file, the block consists of Attributes. Here's the output of what you requested: Command: (entget(car(entsel))) Select object: ((-1 . <Entity name: 259a4a8>) (0 . "INSERT") (330 . <Entity name: 259ac10>) (5 . "78D") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "1") (100 . "AcDbBlockReference") (66 . 1) (2 . "ROT1") (10 20900.0 125.0 0.0) (41 . 25.0) (42 . 25.0) (43 . 25.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0)) "ROT1" is the name of the block, so I assume I did it correctly. Otherwise, the above honestly doesn't tell me much. I could provide a sample file if that's helpful. Thanks, Michael. "Michael Bulatovich" <Please@dont.try> wrote in message
news:<id9pd.37670$Ro.1562379@news20.bellglobal.com>... There are two ways that text entities can be in a block: 1) Plain old MTEXT or TEXT 2) Attributes You access these differently. It sounds like you are trying to edit a title block. Many people use title blocks containing ATTRIBUTES, though some people like to split up the ATTRIBUTES in a separate BLOCK, and leave the other linework, logos, etc in another BLOCK. Enter the following at the command prompt in a drawing with one of your title blocks: (entget(car(entsel))) then hit enter and pick the titleblock. What do you see? -- MichaelB www.michaelbulatovich.com


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service