Author Topic: vlax-add-cmd and acrx_cmd_transparent  (Read 2800 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #15 on: April 20, 2023, 02:20:37 PM »
@vovka

;   MPP returns the middle point between 2 points ...
(defun MPP ( / mid-pt pt1 pt2 )
   (and
      (setq pt1 (getpoint "\nfirst point :") )
      (setq pt2 (getpoint pt1 "\nsecond point :") )
      (setq mid-pt (list (/ (+ (car pt1) (car pt2) ) 2.0) (/ (+ (cadr pt1) (cadr pt2) ) 2.0) ) )
   )
   mid-pt
)

command :
LINE
Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]:
Specify next point or [Close/Undo]:
Specify next point or [Close/Undo]:
(MPP)

It still LOCKS the CURRENT COMMAND
and I have to press ESC to continue the command !

(acad architecture 2022)



BIGAL

  • Swamp Rat
  • Posts: 1429
  • 40 + years of using Autocad
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #16 on: April 20, 2023, 08:27:56 PM »
Another example

(defun c:000 ()(princ (list 0 0 0)))

LINE '000
then pick more points
'000 to go back to this pt
Enter

Make sure you use the single quote before the 000  '000

Yes it works, have used it before, another function that is inbulit is 'Cal

Cal has all sort of extra commands like get a point along a line at a distance, find mid of 2 points which is also m2p. Check help for Cal.
« Last Edit: April 20, 2023, 08:31:11 PM by BIGAL »
A man who never made a mistake never made anything

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #17 on: April 21, 2023, 04:39:08 AM »
@dan allen

Code - Auto/Visual Lisp: [Select]
  1. (defun C:XXX ()
  2.    (while (setq p (getpoint "\nenter a point") ) (command "point" p) )
  3. )
  4.  
  5. (defun :POINT>STRING (pt)
  6.    (if(= (length pt) 2)
  7.       (strcat (rtos (nth 0 pt) 2 12) "," (rtos (nth 1 pt) 2 12) )
  8.       (strcat (rtos (nth 0 pt) 2 12) "," (rtos (nth 1 pt) 2 12) "," (rtos (nth 2 pt) 2 12) )
  9.    )
  10. )
  11.  
  12. ;   MPP returns the middle point between 2 points ...
  13. (defun MPP ( / mid-pt pt1 pt2 )
  14.    (and
  15.       (setq pt1 (getpoint "\nfirst point :") )
  16.       (setq pt2 (getpoint pt1 "\nsecond point :") )
  17.       (setq mid-pt (list (/ (+ (car pt1) (car pt2) ) 2.0) (/ (+ (cadr pt1) (cadr pt2) ) 2.0) ) )
  18.    )
  19.    (vla-SendCommand (vla-get-activedocument (vlax-get-acad-object)) (strcat (:POINT>STRING mid-pt) "\n") )
  20. )
  21.  
  22. (vlax-add-cmd "MPP"  (function MPP) "MPP" acrx_cmd_transparent)
  23.  

Try this :
command : XXX
(enter a point)
(enter a point)

'MPP

danAllen

  • Newt
  • Posts: 134
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #18 on: April 21, 2023, 12:32:57 PM »
@dan allen

Bricscad needs tweak to vlax-add-cmd, see history
: (defun C:XXX ()
(_>    (while (setq p (getpoint "\nenter a point") ) (command "point" p) )
(_> )
C:XXX
: (defun :POINT>STRING (pt)
(_>    (if(= (length pt) 2)
((_>       (strcat (rtos (nth 0 pt) 2 12) "," (rtos (nth 1 pt) 2 12) )
((_>       (strcat (rtos (nth 0 pt) 2 12) "," (rtos (nth 1 pt) 2 12) "," (rtos (nth 2 pt) 2 12) )
((_>    )
(_> )
:POINT>STRING
: (defun MPP ( / mid-pt pt1 pt2 )
(_>    (and
((_>       (setq pt1 (getpoint "\nfirst point :") )
((_>       (setq pt2 (getpoint pt1 "\nsecond point :") )
((_>       (setq mid-pt (list (/ (+ (car pt1) (car pt2) ) 2.0) (/ (+ (cadr pt1) (cadr pt2) ) 2.0) ) )
((_>    )
(_>    (vla-SendCommand (vla-get-activedocument (vlax-get-acad-object)) (strcat (:POINT>STRING mid-pt) "\n") )
(_> )
MPP
: (vlax-remove-cmd "MPP")

; ----- Error around expression -----
(VLAX-REMOVE-CMD MPP)
;
; error : Unknown Error in Lisp or CAD system or 'Stack Overflow'
: (vlax-add-cmd "MPP"  (function MPP) "MPP" acrx_cmd_transparent)

; ----- Error around expression -----
#'MPP
;
; error : bad argument type <NIL> ; expected <INTEGER> at [vlax-add-cmd]
: (vlax-add-cmd "MPP"  (function MPP) "MPP" 1)

; ----- Error around expression -----
#'MPP
;
; error : bad argument type <#<<FUNCTION> #x33 @fffdc4fc6>> ; expected <SYMBOL> at [vlax-add-cmd]
: (vlax-add-cmd "MPP"  'MPP "MPP" 1)
(("MPP" . "MPP"))


seemed to work as expected. Used XXX to add two points, then typed 'MPP, selected two points and a point was created between them

: XXX
enter a point
: point
Settings/Multiple/<Location of point>:
enter a point
: point
Settings/Multiple/<Location of point>:
enter a point'MPP
first point :
second point :
enter a point
: point
Settings/Multiple/<Location of point>:
enter a pointnil

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #19 on: April 21, 2023, 01:41:34 PM »
@dan allen

ok !

with some easy modifications, it seem to work well in BricsCAD !

thank you




danAllen

  • Newt
  • Posts: 134
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #20 on: April 21, 2023, 03:16:56 PM »
...it seem to work well in BricsCAD !

I'm on R15, current version is R23...

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #21 on: June 23, 2023, 03:41:52 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun POINT>STRING (pt)
  2.    (if (= (length pt) 2)
  3.       (strcat (rtos (nth 0 pt) 2 12) "," (rtos (nth 1 pt) 2 12) )
  4.       (strcat (rtos (nth 0 pt) 2 12) "," (rtos (nth 1 pt) 2 12) "," (rtos (nth 2 pt) 2 12) )
  5.    )
  6. )
  7.  
  8.  
  9.  
  10.  
  11. (defun PR ( / oom osa ptr xpt)
  12.    (setq oom (getvar "orthomode") osa (getvar "snapang"))
  13.    (setvar "orthomode" 1)
  14.    (if(setq ptr (getpoint "\nreference point :"))
  15.       (setq xpt (getpoint  ptr "\ntarget point :"))
  16.    )
  17.    (setvar "orthomode"    oom)   (setvar "snapang" osa)
  18.  
  19.    xpt
  20.  
  21.    ;   (vla-SendCommand (ACTIVE-DOCUMENT) (strcat (POINT>STRING xpt) "\n") )
  22.    ;   (dcl-sendstring (strcat (POINT>STRING xpt) "\n") )
  23. )
  24.  
  25.    
  26. (vlax-add-cmd "PR" 'PR "PR" acrx_cmd_transparent)


Try this :
command : LINE (enter)
                 enter a point
                 enter a point
                'PR (enter) . . .

I still don't understand why it doesn't work at all !



« Last Edit: June 23, 2023, 03:45:45 PM by domenicomaria »

ribarm

  • Gator
  • Posts: 3306
  • Marko Ribar, architect
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #22 on: June 23, 2023, 04:24:32 PM »
Maybe I am missing something, but can you achieve this just by :
LINE
click
click
F8 (ortho)
click
...
and so on, so on...
ENTER - finish
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vlax-add-cmd and acrx_cmd_transparent
« Reply #23 on: June 23, 2023, 06:13:31 PM »
@ribarm
I want understand why
(vlax-add-cmd "PR" 'PR "PR" acrx_cmd_transparent)
does not work!
« Last Edit: June 23, 2023, 06:21:11 PM by domenicomaria »