Jump to content

Interactively moving text


Tyke

Recommended Posts

I have created a new text object from two existing text objects and want to get the user to place the new text object interactively in the drawing with a rubber band from the original text position.

 

Getting the rubber band is no problem, but I would like to see the text on the cursor so that the user can place the text optimally in the drawing. I've tried several things but I can't get the text to appear on screen in the placement process.

 

Can anyone offere any advice?

Link to comment
Share on other sites

I assume this is a .NET request. If so then this thread may beinformative.

 

The examples there are not manipulating text objects (circles,actually) but the process is the same.

 

This time its VBA Sean, I'm adding a few more functions to an existing VBA program and time required to translate the whole to .NET cannot be justified at the moment.

 

I'll have a look at Kean's example, but I don't think jigging is an option in VBA.

 

All I'm trying to replicate is the AutoCAD MOVE command where the text sticks to the cursor and has a rubber band to its original position.

Link to comment
Share on other sites

Unfortunately VBA does not offer many options for dynamic visual feedback (referred to as “jigging” in .NET). The only option, I believe, is to make a call to ThisDrawing.SendCommand. That way the Text entity can be manipulated via AutoCAD’s own “Move” command.

 

There are synchroniztion issues with SendCommand, though,(i.e., the commands only get called after the entire VBA code has run). If moving the entily is the final step in the process then SendCommand should work pretty well.

Edited by SEANT
Link to comment
Share on other sites

I'm not too sure how to build the command string together. I have the text in a variable objNewText, the start position for the move in a variable varPoint1 and I want the user to pick the new position for the text (I was using ThisDrawing.Utility.GetPoint(varPoint1, "select new insertion point for the text: ")

Link to comment
Share on other sites

Thanks for that Sean.

 

We've tried it out without the 'ghost' text, that is just with the rubber band, and the guys are having no problems at all using it. So for the moment I shall leave it as it is and when I get a little time I'll add the icing to the cake and develop it a bit further. I've bookmarked your link and ASMI's code looks interesting enough to give it a go.

 

I'm moving away from VBA to VB.NET but every now and then someone brings up a problem or change to existing VBA code and then you're right back in there.

 

Once again thanks for your help.

Link to comment
Share on other sites

What about this code snip:


Option Explicit
Sub dragText()
Dim oEnt As AcadEntity
Dim oText As 
AcadText
Dim pickPt As Variant
Dim cmd As 
String
ThisDrawing.Utility.GetEntity oEnt, pickPt, vbCrLf & "Select 
text"
If Not TypeOf oEnt Is AcadText Then
Exit Sub
End If
Set oText 
= oEnt
Dim basePt As Variant
basePt = oText.InsertionPoint
' you have 
as well to specify base point before,
'basePt = .GetPoint(pickPt, vbCrLf 
& "Specify a base point : ")
Dim hdl As String
hdl = 
oEnt.handle
Dim pt As String
pt = "(list " & Replace(CStr(basePt(0)), 
",", ".") & " " & Replace(CStr(basePt(1)), ",", ".") & 
Replace(CStr(basePt(2)), ",", ".") & ")"
cmd = "(command " & Chr(34) 
& "_move" & Chr(34) & " (handent " & Chr(34) & hdl & 
Chr(34) & ") " & vbCr & Chr(34) & Chr(34) & pt & vbCr 
& "PAUSE)" & vbCr


ThisDrawing.SendCommand cmd
'just a dummy message to  stop command echoing:
MsgBox "pokey"

End Sub

Link to comment
Share on other sites

If you do decide to go the SendCommand route, perhaps this will help:

 

(command "._move" newss "" pt "[color=blue]drag[/color]" pause)

 

This line was pulled from an oldie, but a goodie LISP routine (pre-Visual LISP), that Copied and Rotated a selection set (aptly named CoRo). A few lines earlier in the LISP routine, a copy in place was used, where "pt" represents a user specified base-point from which to both copy, place, and rotate the resultant selection set.

 

I'm unable to translate the syntax for you (from LISP to VBA), or of any limitations in using SendCommand; hopefully this is of *some* use to you conceptually.

 

If this interactive move is not at the end of your current VBA code, perhaps there exists a simple means by which your VBA can be spliced into two parts... the former, which precedes the SendCommand, and the latter, which can be called from the LISP itself? This (if feasible) would at least alleviate the need for VBA->dotNET migration... Just a thought.

 

Cheers! :beer:

Link to comment
Share on other sites

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...