Author Topic: Create ghost image  (Read 2699 times)

0 Members and 1 Guest are viewing this topic.

csgoh

  • Newt
  • Posts: 176
Create ghost image
« on: September 16, 2006, 03:36:41 AM »
I wrote the following lisp to move all text of the same layer.
Code: [Select]
;;; mvrl.LSP
;;;A program to move all the text of a selected layer
 (defun c:mvrl( / ss ss_all ss_layer undomark ntt)
  (prompt "\nTo move all text of same layer\n")
  (setvar "cmdecho" 0)
  (cond
   ((setq ntt (car (entsel "\nSelect the text layer to move   ==> ")))
    (princ)
    (setq ss_layer (wg:dxf 8 ntt))
    (setq ss_all (ssget "X" (list (cons 0 "TEXT")(cons 8 ss_layer))))
    (if (/= ss_all nil)
     (progn
      (undobegin)
      (setq undomark T)
      (command "move" ss_all "")
      (undoend)
     )
     (progn
      (dos_beep 3)
      (alert "\nSelected layer has no text ")
     )
    )
   ); something selected
  );cond
  (princ)
 ); c:mvrl

(defun wg:dxf (code ename)
 (cdr (assoc code (entget ename)))
); wg:dxf

Instead of using the commnd move, I would like to use vlisp to move the texts exactly like the command move. I have no idea how to do it and would appreciate some help.
Thanks

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create ghost image
« Reply #1 on: September 16, 2006, 04:05:58 AM »
Have a look at the VLA-MOVE function

if you need help, yell


... but you will not get ghosting  ..
« Last Edit: September 16, 2006, 04:08:16 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Create ghost image
« Reply #2 on: September 16, 2006, 04:25:56 AM »
unless you mean like this ..

Code: [Select]
;; ...
 (command "move" ss_all "" pause pause )
 ;;...


Edit:added in case Andrea comes to visit :-
Code: [Select]
;; ...
 (command "._MOVE" ss_all "" pause pause )
 ;;...


« Last Edit: September 16, 2006, 04:49:45 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

csgoh

  • Newt
  • Posts: 176
Re: Create ghost image
« Reply #3 on: September 17, 2006, 04:24:51 AM »
Thanks, Kerry. I came up with this using vla-move, but how to highlight all of the texts. As you say, this does not have a ghosting effect, but I am eager to learn to produce a ghosting effect? Any leads to this effect?
Code: [Select]
;;; mvrl.LSP
;;;A program to move all the text of a selected layer
 (defun c:mvrl( / ss ss_all ss_layer undomark ntt alist anObj pt1 pt2)
  (prompt "\nTo move all text of same layer\n")
  (setvar "cmdecho" 0)
  (cond
   ((setq ntt (car (entsel "\nSelect the text layer to move   ==> ")))
    (princ)
    (setq ss_layer (wg:dxf 8 ntt))
    (setq ss_all (ssget "X" (list (cons 0 "TEXT")(cons 8 ss_layer))))
    (if (/= ss_all nil)
     (progn
      (undobegin)
      (setq undomark T)
      (setq alist (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss_all))))
       (if (setq pt1 (getpoint "\nBase point .. "))
         (progn
           (setq pt2 (getpoint pt1 "Move To Point .. "))
           (repeat (length alist)
            (setq anObj (car alist)
                  alist (cdr alist)
            )
            (vla-move anObj (vlax-3d-point pt1) (vlax-3d-point pt2))
           )
           (undoend)
         )
       )
;      (command "move" ss_all "")
     )
     (progn
      (dos_beep 3)
      (alert "\nSelected layer has no text ")
     )
    )
   ); something selected
  );cond
  (princ)
 ); c:mvrl

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Create ghost image
« Reply #4 on: September 17, 2006, 05:09:06 PM »
Here's something that Doug Broad posted to the autodesk newsgroups that he obtained from Frank Whaley of Autodesk......
Quote
Ghosting/Dragging by Using Express Tools Functions (10 replies)   
Posted by: Broad, Doug
Date: Aug/29/01 - 12:15 (GMT)   
To All,

There have been several discussions on dragging/ghosting within a LISP/ARX
routine without using the command. The following has been brought to my
attention by Frank Whaley (Thanks Frank). It may benefit those who already have the Express Tools. With Frank's permission,
I quote:

The Express Tools team encountered similar problems(referring to dragging), so we developed three functions that use
underlying ObjectARX utilities:

(acet-ss-drag-move <ss> <pt> [<prompt>] [<highlight> [<cursor>]])
(acet-ss-drag-rotate <ss> <pt> [<prompt>] [<highlight> [<cursor>]])
(acet-ss-drag-scale <ss> <pt> [<prompt>] [<highlight> [<cursor>]])

Arguments:
ss
The selection set to drag.

pt
The base point.

prompt
If supplied, a message to display before dragging is started.

highlight
If supplied, causes a rubber-band line to be drawn from <pt> to the current
cursor position while dragging; this parameter can be NIL to draw a rubber-band
line in the inverse of the screen color, or non-NIL to draw a highlighted line.

cursor
If supplied, the cursor form to display while dragging (0=crosshairs, 1=no
cursor, 2=target).

Return values:
move:
Normally returns the selected point, but will honor '(initget)' settings and can
return arbitrary text or keywords. Returns NIL if the dragging operation is
aborted.

rotate:
The selected rotation value (radians), or NIL if dragging is aborted.

scale:
The selected scale factor, or NIL if dragging is aborted.

~~~~~~~~~END QUOTED SECTION~~~~~~~~~~~
(referring to dragging) note is mine.

For those who own the Express Tools, use

(arxload "acetutil")

This loads the ACETUTIL.ARX set of functions. If this returns an error, either you do not have the Express Tools or the path
is not in the support file listing.

Then draw some entities and try

(acet-ss-drag-move (ssget) (getpoint "\nBasepoint: "))

I believe Autodesk has no problem with owners of the Express Tools calling these functions from within functions they develop
and use. There is a move to make some of these functions available others who do not own the Express Tools.

I have tried these functions and they appear to work very well.

Hope this of help,

Doug Broad

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Create ghost image
« Reply #5 on: September 17, 2006, 05:14:48 PM »
And something that was posted here by Luis E. (I think, if it was someone else please let me know.)
Code: [Select]
;; ability to drag an move a vla-object block
;; msg: optional message by default uses "Move"
(defun rwiz-drag-move  (msg obj / take code5 p3)
  (prompt (strcat "\n"
    (cond (msg)
   ("Move"))
    "\n"))
  (while (and (setq take (grread 't)) (/= (car take) 3))
    (setq code5 (car take)
   p3 (cadr take))
    (if (and p3 (= code5 5))
      (vla-move obj
  (vla-get-insertionpoint obj)
  (vlax-3d-point p3)))))

(defun C:TST  (/ ename)
  (if (setq ename (car (entsel "\nSelect block: ")))
    (rwiz-drag-move nil (vlax-ename->vla-object ename)))
  (princ))

csgoh

  • Newt
  • Posts: 176
Re: Create ghost image
« Reply #6 on: September 18, 2006, 08:24:10 PM »
Thanks, Jeff.