Jump to content

Writing a text programmatically without a text object


Recommended Posts

Posted

Hello,

 

I need to create some texts using the following command in VBA:

ThisDrawing.SendCommand ("Text" & vbCr & "10,10,0" & vbCr & vbCr & vbCr)

 

But, I must enter the text manually. I want to enter the text programmatically. How?

 

Thank you

Posted

You can do it by lisp also.... why do you need VBA???

Posted

Could a string returned from:

ThisDrawing.Utility.GetString()

Be used with the standard AddText method? That would allow manual text input yet avoid the issues associated with SendCommand.

Posted

Hello Satish,

 

In fact, I am using a lisp file named "KATEB":

ThisDrawing.SendCommand ("KATEB" & vbCr & "10,10,0" & vbCr & vbCr & vbCr)

 

this lisp file converts english texts to Farsi (persian). I'm creating a Tool kit for my works, and in one of them I want to read texts from a Textbox and programmatically write texts to Farsi.

Posted

without being familiar with this KATEB lisp command prompts makes it difficult to give you a solution - where in your SendCommand are you specifying the string you are translating to Farsi?

 

ThisDrawing.SendCommand ("KATEB" & vbCr & "10,10,0" & vbCr & vbCr & vbCr & sTextToInsert)

 

but that code is going to insert each item into the same location, so you would need some variables for your text insertion points too

 

I'm sure most people will agree that using SendCommand is a last resort, but in your case I can see why you are doing it, because you dont have a VBA function that converts English to Farsi, and you are relying on LISP that you dont want to write, or just plain dont know how to write.

 

Do you have any contact information for the author of the KATEB code? usually the author leaves some sort of contact details on the website where you get the code in the first place

Posted

Hello abraxus,

The code that I wrote is a sample. You can use the Text command to examine. When you execute this routine:

sub Text()

ThisDrawing.SendCommand ("Text" & vbCr & "10,10,0" & vbCr & vbCr & vbCr)

end sub

 

the autocad is waiting to enter a text manually. The sTextToInsert that you wrote is not executed and focus is given to AutoCAD.

Posted

you cannot use send command to prompt for text

 

you have to have it "saved up" programatically

Posted

explain your programming experience then, dude, im not going to just write code for you - never use "sendCommand"

Posted

since your code depends on a LISP command that cannot be substituted, name the source of your lisp command

Posted

I think it's better that convert the lisp to VB code.

Posted

i agree - but can you do that? if you can, then you can use all the flexibility of vba - passing vba variables lisp is too complex

Posted

Yes, I already changed a lisp to vb. It's easy, but time-consuming.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...