Author Topic: Express Tool Function, only, without the Express Tools...  (Read 9130 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Express Tool Function, only, without the Express Tools...
« on: May 23, 2009, 06:02:44 PM »
Just thought I'd share this with you.

I have been working on a function to replicate that of "acet-ss-drag-move", so that it can be used without the hassle of having Express Tools loaded. I based it on a method posted on here some time ago by Luis I think. Not sure if one of these has been made before, but I'll post this anyway  :kewl:

Code: [Select]
[color=#990099];; Ghosting Example (SS), by Lee McDonnell[/color]
[color=#990099];; Args:[/color]
[color=#990099];; msg ~ prompt        [str][/color]
[color=#990099];; ss  ~ selection set [selset][/color]
[color=#990099];; pt  ~ base point    [pt][/color]
[color=#990099];; hi  ~ rubber band   [t/nil][/color]

[color=RED]([/color][color=BLUE]defun[/color] lmac-ss-drag-move [color=RED]([/color]msg ss pt hi  [color=BLUE]/[/color] oBjLst MiP MaP
                                          bsvec cPLst gr[color=RED])[/color]
  [color=RED]([/color][color=BLUE]vl-load-com[/color][color=RED])[/color]
  [color=RED]([/color][color=BLUE]if[/color] msg
    [color=RED]([/color][color=BLUE]prompt[/color]
      [color=RED]([/color][color=BLUE]strcat[/color]
        [color=RED]([/color][color=BLUE]if[/color] [color=RED]([/color][color=BLUE]not[/color] [color=RED]([/color][color=BLUE]vl-string-search[/color] [color=#ff00ff]"\n"[/color] msg[color=RED])[/color][color=RED])[/color]
          [color=#ff00ff]"\n"[/color][color=#ff00ff]""[/color][color=RED])[/color] msg[color=RED])[/color][color=RED])[/color][color=RED])[/color]
  [color=RED]([/color][color=BLUE]setq[/color] oBjLst
    [color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color][color=BLUE]vlax-ename->vla-object[/color]
      [color=RED]([/color][color=BLUE]vl-remove-if[/color] [color=DARKRED]'[/color][color=BLUE]listp[/color]
        [color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color][color=BLUE]cadr[/color]
          [color=RED]([/color][color=BLUE]ssnamex[/color] ss[color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color]
  [color=RED]([/color][color=BLUE]vla-getBoundingBox[/color]
    [color=RED]([/color][color=BLUE]car[/color] oBjLst[color=RED])[/color] [color=DARKRED]'[/color]MiP [color=DARKRED]'[/color]MaP[color=RED])[/color]
      [color=RED]([/color][color=BLUE]setq[/color] bsvec
        [color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color][color=BLUE]-[/color]
          [color=RED]([/color][color=BLUE]vlax-safearray->list[/color] MiP[color=RED])[/color] pt[color=RED])[/color][color=RED])[/color]
  [color=RED]([/color][color=BLUE]mapcar[/color]
    [color=RED]([/color][color=BLUE]function[/color]
      [color=RED]([/color][color=BLUE]lambda[/color] [color=RED]([/color]x[color=RED])[/color]
        [color=RED]([/color][color=BLUE]vla-highlight[/color] x :vlax-true[color=RED])[/color][color=RED])[/color][color=RED])[/color]
          [color=RED]([/color][color=BLUE]setq[/color] cpLst
            [color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color][color=BLUE]vla-copy[/color] oBjLst[color=RED])[/color][color=RED])[/color][color=RED])[/color]
  [color=RED]([/color][color=BLUE]while[/color]
      [color=RED]([/color][color=BLUE]not[/color]
        [color=RED]([/color][color=BLUE]eq[/color] [color=#009900]3[/color]
          [color=RED]([/color][color=BLUE]car[/color]
            [color=RED]([/color][color=BLUE]setq[/color] gr [color=RED]([/color][color=BLUE]grread[/color] [color=DARKRED]'[/color]t[color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color]
              [color=RED]([/color][color=BLUE]redraw[/color][color=RED])[/color]
      [color=RED]([/color][color=BLUE]if[/color]
        [color=RED]([/color][color=BLUE]and[/color]
          [color=RED]([/color][color=BLUE]eq[/color] [color=#009900]5[/color] [color=RED]([/color][color=BLUE]car[/color] gr[color=RED])[/color][color=RED])[/color]
            [color=RED]([/color][color=BLUE]listp[/color] [color=RED]([/color][color=BLUE]cadr[/color] gr[color=RED])[/color][color=RED])[/color][color=RED])[/color]
        [color=RED]([/color][color=BLUE]progn[/color]
          [color=RED]([/color][color=BLUE]vla-getBoundingBox[/color]
            [color=RED]([/color][color=BLUE]car[/color] oBjLst[color=RED])[/color] [color=DARKRED]'[/color]MiP [color=DARKRED]'[/color]MaP[color=RED])[/color]
              [color=RED]([/color][color=BLUE]mapcar[/color]
                [color=RED]([/color][color=BLUE]function[/color]
                  [color=RED]([/color][color=BLUE]lambda[/color] [color=RED]([/color]x[color=RED])[/color]
                    [color=RED]([/color][color=BLUE]vla-move[/color] x
                      [color=RED]([/color][color=BLUE]vlax-3D-point[/color]
                        [color=RED]([/color][color=BLUE]mapcar[/color] [color=DARKRED]'[/color][color=BLUE]-[/color]
                          [color=RED]([/color][color=BLUE]vlax-safearray->list[/color] MiP[color=RED])[/color] bsVec[color=RED])[/color][color=RED])[/color]
                            [color=RED]([/color][color=BLUE]vlax-3D-point[/color]
                              [color=RED]([/color][color=BLUE]cadr[/color] gr[color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color]
                                oBjLst[color=RED])[/color]
          [color=RED]([/color][color=BLUE]if[/color] hi
            [color=RED]([/color][color=BLUE]grdraw[/color] pt [color=RED]([/color][color=BLUE]cadr[/color] gr[color=RED])[/color] [color=#009900]3[/color] [color=#009900]1[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color]
  [color=RED]([/color][color=BLUE]mapcar[/color]
    [color=RED]([/color][color=BLUE]function[/color]
      [color=RED]([/color][color=BLUE]lambda[/color] [color=RED]([/color]x[color=RED])[/color]
        [color=RED]([/color][color=BLUE]vl-catch-all-apply[/color]
          [color=DARKRED]'[/color][color=BLUE]vla-delete[/color]
            [color=RED]([/color][color=BLUE]list[/color] x[color=RED])[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color] cpLst[color=RED])[/color]
  [color=RED]([/color][color=BLUE]redraw[/color][color=RED])[/color][color=RED])[/color]

[color=#990099];; Test Function[/color]

[color=RED]([/color][color=BLUE]defun[/color] c:test  [color=RED]([/color][color=BLUE]/[/color] ss pt[color=RED])[/color]
  [color=RED]([/color][color=BLUE]if[/color] [color=RED]([/color][color=BLUE]and[/color] [color=RED]([/color][color=BLUE]setq[/color] ss [color=RED]([/color][color=BLUE]ssget[/color][color=RED])[/color][color=RED])[/color]
           [color=RED]([/color][color=BLUE]setq[/color] pt [color=RED]([/color][color=BLUE]getpoint[/color] [color=#ff00ff]"\nSelect Base Point: "[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color]
    [color=RED]([/color]lmac-ss-drag-move [color=BLUE]nil[/color] ss pt [color=BLUE]t[/color][color=RED])[/color][color=RED])[/color][color=RED])[/color]


Patrick_35

  • Guest
Re: Express Tool Function, only, without the Express Tools...
« Reply #1 on: May 25, 2009, 07:31:05 AM »
Hi

This seems complicated

why not use
Code: [Select]
(vl-cmdf "_.move" (ssget) pause pause)
@+

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Express Tool Function, only, without the Express Tools...
« Reply #2 on: May 25, 2009, 07:35:28 AM »
I wanted to avoid using the command call, but still create the same effect  :-)

Maybe unnecessary, but I enjoyed doing it  :wink:

velasquez

  • Newt
  • Posts: 195
Re: Express Tool Function, only, without the Express Tools...
« Reply #3 on: January 09, 2010, 06:42:57 AM »
Hi Lee   
Excellent your work with this function. 
Doesn't a way exist of hiding the original object?   
I need to show a block being just dragged. 
Exactly as the function that I posted.

Thanks
Velasquez

Code: [Select]
;;;Drag a selection set to change location.
;;;
;;;Arguments
;;;ss The selection set to drag.
;;;pt The base point.
;;;prompt A message to display before dragging is started.
;;;highlight If given, 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 The cursor form to display while dragging (0=crosshairs, 1=no cursor, 2=target).
;;;
;;;Return Values
;;;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.
;;;
(defun JoyArrast (BlockName /)
  (vla-move
    (vla-InsertBlock
      (vla-get-ModelSpace
(vla-get-activeDocument (vlax-get-acad-object))
      ) ;_ fim de vla-get-ModelSpace
      (vlax-3d-point '(0. 0. 0.))
      BlockName
      1.
      1.
      1.
      0.
    ) ;_ fim de vla-InsertBlock
    (vlax-3d-point '(0. 0. 0.))
    (vlax-3d-point (acet-ss-drag-move
     (ssadd (entlast))
     '(0. 0. 0.)
     "\nSpecify insertion point: "
   ) ;_ fim de acet-ss-drag-move
    ) ;_ fim de vlax-3d-point
  ) ;_ fim de vla-move
) ;_ fim de defun

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Express Tool Function, only, without the Express Tools...
« Reply #4 on: January 09, 2010, 02:04:09 PM »
Something like this?

Code: [Select]
(defun lmac-blk-drag-move (msg obj / gr)
  (princ msg)
  (while (eq 5 (car (setq gr (grread 't 4 0))))
    (vla-put-insertionPoint obj (vlax-3D-point (cadr gr))))
 
  (cadr gr))

(defun c:test (/ blk)
  (vl-load-com)

  (if (setq blk (getfiled "Select Block" "" "dwg" 16))
    (lmac-blk-drag-move "\nPlace Block..."
      (vla-insertblock
        (vla-get-ModelSpace
          (vla-get-ActiveDocument
            (vlax-get-acad-object)))
        (vlax-3D-point (getvar "VIEWCTR")) blk 1. 1. 1. 0.)))

  (princ))

velasquez

  • Newt
  • Posts: 195
Re: Express Tool Function, only, without the Express Tools...
« Reply #5 on: January 10, 2010, 08:26:10 AM »
 
 
Great Lee,
Very good, that is exactly the one that I need.
 
See what I am trying to do. 
1 - my user chooses a product in a relationship. 
2 - I need to draw this and to create a block if he doesn't exist. 
3 - to use lmac-blk-drag-moves  :-D to show the block while he/she asks for the insert point. 
 
Do you think can have some problem to draw this in ' (0. 0. 0.) if the point is not visible? 
Please if you have a suggestion she will be very well coming. 
 
Tanks 
velasquez 
 

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Express Tool Function, only, without the Express Tools...
« Reply #6 on: January 10, 2010, 11:11:41 AM »
One of the major drawbacks of using a GrRead to place objects, is that it doesn't inherently support OSnap, so this functionality must be created manually - which can take a lot of coding, depending on how far you are prepared to take it.

Lee

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Express Tool Function, only, without the Express Tools...
« Reply #7 on: January 10, 2010, 12:00:49 PM »
Wondering why the C folks or the VBA for that matter haven't provided a replacement for the grread function but with snaps.  :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Express Tool Function, only, without the Express Tools...
« Reply #8 on: January 10, 2010, 01:11:27 PM »
Quote
Wondering why the C folks or the VBA for that matter haven't provided a replacement for the grread function but with snaps.
the job was done almost 4 years ago :)
http://www.theswamp.org/index.php?topic=9133.0

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Express Tool Function, only, without the Express Tools...
« Reply #9 on: January 10, 2010, 01:24:56 PM »
Oops, I missed that one.
Although I still use ACAD2000. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

rhino

  • Guest
Re: Express Tool Function, only, without the Express Tools...
« Reply #10 on: January 10, 2010, 02:27:34 PM »
Oops, I missed that one.
Although I still use ACAD2000. :)


isn't ACAD 2000 like dated??
I remember something abt the layout tab etc and the plot manager being a lot different then...

I learnt AutoCAD on release 14 - but then quickly jumped to 2002 etc etc - use 2007 at work - n 2008 on my laptop

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Express Tool Function, only, without the Express Tools...
« Reply #11 on: January 10, 2010, 03:28:17 PM »
Quote
Wondering why the C folks or the VBA for that matter haven't provided a replacement for the grread function but with snaps.
the job was done almost 4 years ago :)
http://www.theswamp.org/index.php?topic=9133.0

Just tested that program - and I must say, what an awesome piece of work... I just used the test function provided, but, after studying the arguments, the possibilities could be endless... wish I knew Arx, I feel so inadequate after seeing that  :oops:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Express Tool Function, only, without the Express Tools...
« Reply #12 on: January 10, 2010, 03:28:56 PM »
Oops, I missed that one.
Although I still use ACAD2000. :)


isn't ACAD 2000 like dated??
I remember something abt the layout tab etc and the plot manager being a lot different then...

I learnt AutoCAD on release 14 - but then quickly jumped to 2002 etc etc - use 2007 at work - n 2008 on my laptop
Well, I'm a little dated but I hope no one tries to get rid of me.  :evil:

I'm afraid I spent my money on other things besides ACAD and don't seem to have suffered from it. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

velasquez

  • Newt
  • Posts: 195
Re: Express Tool Function, only, without the Express Tools...
« Reply #13 on: January 11, 2010, 06:31:21 AM »
One of the major drawbacks of using a GrRead to place objects, is that it doesn't inherently support OSnap, so this functionality must be created manually - which can take a lot of coding, depending on how far you are prepared to take it.

Lee

Hi Lee 
I am willing to take this ahead. 
But perhaps my knowledge are not very good. 
I intend to try even so. 
Perhaps this can be made together with more people. 
Thanks 
velasquez

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Express Tool Function, only, without the Express Tools...
« Reply #14 on: January 11, 2010, 06:38:43 AM »
One of the major drawbacks of using a GrRead to place objects, is that it doesn't inherently support OSnap, so this functionality must be created manually - which can take a lot of coding, depending on how far you are prepared to take it.

Lee

Hi Lee 
I am willing to take this ahead. 
But perhaps my knowledge are not very good. 
I intend to try even so. 
Perhaps this can be made together with more people. 
Thanks 
velasquez

Well, to avoid some of the trouble, take a look at the link that VovKa has posted - you should be able to engineer something with DynDraw  :-)

velasquez

  • Newt
  • Posts: 195
Re: Express Tool Function, only, without the Express Tools...
« Reply #15 on: January 11, 2010, 07:13:33 AM »
Great contribution DynDraw. 
Will VovKa maintain free updatings? 
velasquez

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Express Tool Function, only, without the Express Tools...
« Reply #16 on: January 11, 2010, 07:57:20 AM »
Will VovKa maintain free updatings?
VovKa will not. Not because he is a bad guy, just not the author :)
You'd better talk to Alexander Rivilis

velasquez

  • Newt
  • Posts: 195
Re: Express Tool Function, only, without the Express Tools...
« Reply #17 on: January 11, 2010, 08:28:27 AM »
Will VovKa maintain free updatings?
VovKa will not. Not because he is a bad guy, just not the author :)
You'd better talk to Alexander Rivilis

Please excuse me for the confusion with the names.
velasquez