Comando:_line
Specificare primo punto: >>> [_Button("« Middle Point"...
>>First point <Lastpoint> <13.09,398.28,0>: >>> [_Button("« Middle Point"...
>>First point <Lastpoint> <13.09,398.28,0>: >>> [_Button("« Middle Point"...
>>First point <Lastpoint> <13.09,398.28,0>:
>>Second point:
>>Second point:
>>Second point: nil
Specificare punto successivo o [Annulla]:
; [_Button("« Middle Point", OsnMedio, OsnMedio)]^P$M=$(if,$(getvar,cmdactive),(ALE_MidPoint """""""ACTIVE"""""""),(ALE_MidPoint nil));
; [_Button("« Progressive Distance", OsnALE_DistPr, OsnALE_DistPr)]^P$M=$(if,$(getvar,cmdactive),(ALE_DistPr """""""ACTIVE"""""""),(ALE_DistPr nil));
; Example (no nesting - only for command line)
(setq *acDoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-remove-cmd "mf")
(vlax-add-cmd "mp" 'Ale_MP "mp")
(defun Ale_MP ( )
(vla-SendCommand *acDoc* "!(ALE_MidPoint \"ACTIVE\") ")
)
;
; ALE_GetPoint - Alessi Marc'Antonio 20/02/93
; IGtBit > (1 = not null, 0 for none) same of INITGET
; KwdStr = key word ("" for none) same of INITGET
; PrmStr = prompt string, a default as <DefPnt> (nil for none)
; will be added and a : will be added
; BasPtn = base point (nil for none)
;
; Example:
; (setq #GlVal (ALE_GetPoint 40 "" "Inser point <Lastpoint>" #GlVal #GlVal))
;
(defun ALE_GetPoint (IGtBit KwdStr PrmStr DefPnt BasPtn / InpVal DefStr ZetPnt)
(if DefPnt
(setq
ZetPnt (caddr DefPnt)
DefStr
(strcat
(rtos (car DefPnt)) ","
(rtos (cadr DefPnt)) ","
(if ZetPnt (rtos ZetPnt) "0")
)
PrmStr (strcat "\n" PrmStr " <" DefStr ">: ")
IGtBit (logand IGtBit 254)
)
(setq PrmStr (strcat "\n" PrmStr ": "))
)
(setq InpVal "NOTVALIDSTRING" IGtBit (+ IGtBit 128))
(while
(not
(or
(= 'LIST (type InpVal))
(null InpVal)
(if (= 'STR (type InpVal))
(or
(= 'LIST (type (read InpVal)))
(wcmatch KwdStr (strcat "*" InpVal "*"))
)
)
)
)
(initget IGtBit KwdStr)
(setq InpVal (if BasPtn (getpoint BasPtn PrmStr) (getpoint PrmStr)))
)
(if InpVal
(if (or (/= 'STR (type InpVal)) (atom (read InpVal)))
InpVal
(eval
(if (= "ACTIVE" (cadr (read InpVal)))
(subst nil "ACTIVE" (read InpVal))
(read InpVal)
)
)
)
DefPnt
)
)
(defun ALE_MidPoint (CmdAct / BasPtn Pnt001 CurBlp CurOrt CurOsn)
(graphscr)
(setq CurBlp (getvar "BLIPMODE") CurOrt (getvar "ORTHOMODE"))
(setvar "BLIPMODE" 1) (setvar "ORTHOMODE" 0)
(setq
BasPtn (ALE_GetPoint 40 "" ">>First point <Lastpoint>" (getvar "LASTPOINT") (getvar "LASTPOINT"))
Pnt001 (ALE_GetPoint 41 "" ">>Second point" nil BasPtn)
CurOsn (getvar "OSMODE")
)
(setvar "OSMODE" 0)
(setq BasPtn (polar BasPtn (angle BasPtn Pnt001) (/ (distance BasPtn Pnt001) 2.0)))
(setvar "BLIPMODE" CurBlp) (setvar "ORTHOMODE" CurOrt) (setvar "OSMODE" CurOsn)
(cond
( (and BasPtn CmdAct) (command "_NONE" BasPtn) )
( BasPtn )
( T (alert "Asso message:\nMidpoint not found." ) (princ) )
)
)
(defun ALE_DistPr (CmdAct / BasPtn Pnt001 DstTot CurOrt CurBlp)
(graphscr)
(setq CurOrt (getvar "ORTHOMODE") CurBlp (getvar "BLIPMODE" ))
(setvar "ORTHOMODE" 1) (setvar "BLIPMODE" 1)
(setq
DstTot 0
BasPtn (ALE_GetPoint -88 "" ">>Reference point <Lastpoint>" (getvar "LASTPOINT") nil)
)
(while
(setq Pnt001 (ALE_GetPoint -88 "" ">><Next point>/Return to quit" nil BasPtn))
(setq DstTot (+ DstTot (distance BasPtn Pnt001)))
(prompt
(strcat
"\n>>Distance: " (rtos (distance BasPtn Pnt001)) " Angle: " (angtos (angle BasPtn Pnt001))
" Total distance: " (rtos DstTot) "\n "
)
)
(grdraw BasPtn Pnt001 -1 1) (setq BasPtn Pnt001)
)
(setvar "ORTHOMODE" CurOrt) (setvar "BLIPMODE" CurBlp)
(cond
( (and BasPtn CmdAct) (command "_NONE" BasPtn) (princ) )
( BasPtn )
( T (alert "Asso message:\nPoint not found." ) (princ) )
)
)
I use this method for many years (perhaps should be improved ...)
For example you can nest multiple ALE_MidPoint functions (or similar) during a command or
in response to a Lisp function (nesting has some problem in Bricscad...)
...
Hi Marc'Antonio,I do not quite understand what you mean, have you tried my functions?
For some reason this method has not been working for me since AutoCAD 2009 I think. ...
It is recommended that you use the vlax-add-cmd function from a separate-namespace VLX. You should then explicitly load the VLX using the APPLOAD command, rather than by placing it in one of the startup LISP files.
Yes I did. I still do not understand how he is overcoming the fact that < ... >
he is me
he is me
And the walrus was Paul.
he is me.
I'll have a look tonight if you don't get it resolved .. about 12 hours away.
Sorry, I am not sure what that a rotated (getcorner) is. Here is what I am looking for:AutoCAD 2013 (sorry for italian prompt):
Start the line command, before selecting your first point, shift+right click and use the command modifier "FROM". Now select the basepoint, now for the offset distance, I do not get a "rubberband" that uses polar tracking. I am "blindly" having to select the offset point angle when using direct distance input.
Contrast this with the end point of the line command. If I use the "from" command modifier on the end point, all of a sudden I get to use the rubberband w/ polar tracking when specifying the offset point.
I am trying to make a custom "from" command modifier that uses the rubberband in all circumstances.
...
; [_Button...]^P$M=$(if,$(getvar,cmdactive),(ALE_From """""""ACTIVE"""""""),(ALE_From nil));
(defun ALE_From (CmdAct / BasPtn Pnt001 CurBlp CurOrt)
(graphscr)
(setq CurBlp (getvar "BLIPMODE") CurOrt (getvar "ORTHOMODE"))
(setvar "BLIPMODE" 1) (setvar "ORTHOMODE" 0)
(setq
BasPtn (ALE_GetPoint 40 "" ">>Base point <Lastpoint>" (getvar "LASTPOINT") (getvar "LASTPOINT"))
Pnt001 (ALE_GetPoint 41 "" ">>Offset" nil BasPtn)
)
(setvar "BLIPMODE" CurBlp) (setvar "ORTHOMODE" CurOrt)
(cond
( (and Pnt001 CmdAct) (command "_NONE" Pnt001) (princ) )
( Pnt001 )
( T (alert "Point not found." ) (princ) )
)
)
(defun C:CircleTest (/ Pnt001 EntLas SelSet)
(setq Pnt001 (ALE_GetPoint 40 "" "Circle center <Lastpoint>" (getvar "LASTPOINT") (getvar "LASTPOINT")))
(setq #mdist (ALE_GetDist 46 "" "Circle diameter" #mdist Pnt001))
(command "_.CIRCLE" "_NONE" Pnt001 (/ #mdist 2.0))
(setvar "LASTPOINT" Pnt001)
(princ)
)
(defun ALE_GetDist (IGtBit KwdStr PrmStr DefRea BasPtn / InpVal)
(if DefRea
(setq
PrmStr (strcat "\n" PrmStr " <" (rtos DefRea) ">: ")
IGtBit (logand IGtBit 254)
)
(setq PrmStr (strcat "\n" PrmStr ": "))
)
(initget IGtBit KwdStr)
(setq InpVal (if BasPtn (getdist BasPtn PrmStr) (getdist PrmStr)))
(if InpVal InpVal DefRea)
)
Edit: upoint = ALE_GetPoint
Hi Marc'Antonio,I do not quite understand what you mean, have you tried my functions?
For some reason this method has not been working for me since AutoCAD 2009 I think. ...
I am using in all versions of AutoCAD/Bricscad since it was introduced the bit 128 for initget (maybe 1990).
Try to make the two buttons:
[_Button("« Middle Point", YourIcon, YourIcon)]^P$M=$(if,$(getvar,cmdactive),(ALE_MidPoint """""""ACTIVE"""""""),(ALE_MidPoint nil));
[_Button("« Progressive Distance", YourIcon2, YourIcon2)]^P$M=$(if,$(getvar,cmdactive),(ALE_DistPr """""""ACTIVE"""""""),(ALE_DistPr nil));
and test ALE_MidPoint or ALE_DistPr inside a command or AutoLisp function.
It's frustrating because I'd thought I had this working about 12 or so years ago ... I used a lot of Separate Namespace apps back then.
It might just be oldtimers syndrome.
Hi Marc - Yes I tried your functions. What I specifically was attempting was the command line transparent command that you added with (vlax-add-cmd). I still have the same problem as the OP. Your buttons don't use the command line shortcut.Honestly now I can not get my example with "vla-SendCommand", maybe I am way off base... 8-) I'll try again but I'm not very motivated because I saw that in Bricscad there are other problems with (vlax-add-cmd ...).
(defun ALE_Track (CmdAct / BasPtn Pnt001 CurBlp CurOrt)
(graphscr)
(setq CurBlp (getvar "BLIPMODE") CurOrt (getvar "ORTHOMODE"))
(setvar "BLIPMODE" 1) (setvar "ORTHOMODE" 1)
(setq
BasPtn (ALE_GetPoint 40 "" ">>Base point <Lastpoint>" (getvar "LASTPOINT") (getvar "LASTPOINT"))
Pnt001 (ALE_GetPoint -88 "" ">>Distance" nil BasPtn)
)
(setvar "BLIPMODE" CurBlp) (setvar "ORTHOMODE" CurOrt)
(cond
( (and Pnt001 CmdAct) (command "_NONE" Pnt001) (princ) )
( Pnt001 )
( T (alert "Point not found." ) (princ) )
)
)
(defun ALE_TR ( )
(vla-SendCommand *acDoc* "!(ALE_Track \"ACTIVE\") ")
)
(vlax-add-cmd "tr" 'ALE_TR "tr" 1)
Command: L LINE(defun ALE_TL ( )
(vla-SendCommand *acDoc* "(ALE_Track \"ACTIVE\")\n")
)
(vlax-add-cmd "tl" 'ALE_TL "tl" 1)
Comando: CIRCLETEST
Circle center <Lastpoint> <191.56,101.55,0>: 'tl
Ripresa del comando CIRCLETEST.
Circle center <Lastpoint> <191.56,101.55,0>: (ALE_Track "ACTIVE")
>>Base point <Lastpoint> <191.56,101.55,0>:
>>Offset:
Circle diameter <31.6>:
Here is the command line test:Code: [Select](defun ALE_TR ( )
Command: L LINE
(vla-SendCommand *acDoc* "!(ALE_Track \"ACTIVE\") ")
)
(vlax-add-cmd "tr" 'ALE_TR "tr" 1)
Specify first point: 'tr
Resuming LINE command.
Specify first point: !(ALE_Track "ACTIVE")
>>Base point <Lastpoint> <139.32,394.28,0>:
>>Offset:
Specify next point or [Undo]:
In Bricscad we need a "\n" inside "(ALE_Track \"ACTIVE\")\n" instead of space, works in AutoCAD also.
Inside Lisp we do not need "!" before:
Marc'Antonio#1: Yes but with this version:
Are you saying you can get that to work in multiple documents from the command line ??
Which version of ALE_Track are you using in AutoCAD ?
(defun ALE_TR ( / obj)
(setq obj (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-SendCommand obj "!(ALE_Track \"ACTIVE\")\n")
(vlax-release-object obj)
)
#2: this (prompt "Distance" was "Offset" but the function is the same):(defun ALE_Track (CmdAct / BasPtn Pnt001 CurBlp CurOrt)
(graphscr)
(setq CurBlp (getvar "BLIPMODE") CurOrt (getvar "ORTHOMODE"))
(setvar "BLIPMODE" 1) (setvar "ORTHOMODE" 1)
(setq
BasPtn (ALE_GetPoint 40 "" ">>Base point <Lastpoint>" (getvar "LASTPOINT") (getvar "LASTPOINT"))
Pnt001 (ALE_GetPoint -88 "" ">>Distance" nil BasPtn)
)
(setvar "BLIPMODE" CurBlp) (setvar "ORTHOMODE" CurOrt)
(cond
( (and Pnt001 CmdAct) (command "_NONE" Pnt001) (princ) )
( Pnt001 )
( T (alert "Point not found." ) (princ) )
)
)
Have you tried opening a 2nd drawing in the same session and testing if the command still works? That's the problem is it doesn't work if you open a 2nd drawing in the same session.See #1 on previous post
If the OP just wanted a button I don't think it would be an issue. I was under the impression that he also wanted a transparent command that you can use with ( ' ) in front of it. The whole point of my replies is that there used to be a working method for this - but it doesn't work anymore. (vlax-add-cmd) does not want to function in MDI mode.
(defun ALE_TR ( / obj)
(setq obj (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (eq 3 (getvar 'CMDACTIVE))
(vla-SendCommand obj "!(ALE_Track \"ACTIVE\")\n")
(vla-SendCommand obj "(ALE_Track nil)\n")
)
(vlax-release-object obj)
)
The only problem in Bricscad is vlax-remove-cmd get error if cmd is not definited also with vl-catch-all-apply:Hi Marc'Antonio, can you confirm you are able to open a new drawing, load your routines, run the commands.Yes.
then, open a new drawing in the same session and load the necessary files, then run the commands.Yes.
then, switch to the first drawing in the session and run the commands. ie: typical MDI operations.Yes, but, at this moment, ONLY if I reload ALE_AddCommand.lsp (see below).
if you can do this without error could you advise the load sequence/procedure for the files you are using (into the initial and subsequent drawings) please.
Are you compiling as VLX ? if so what are you compiling and with which switches?Sorry, not tested. :-(
; ALE_AddCommand.lsp
;
(vlax-remove-cmd "tr")
(vlax-add-cmd "tr" 'ALE_TR "tr" 1)
;
(defun ALE_TR ( / obj) ; version 1.00
(setq obj (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (eq 3 (getvar 'CMDACTIVE))
(vla-SendCommand obj "!(ALE_Track \"ACTIVE\")\n")
(vla-SendCommand obj "(ALE_Track nil)\n")
)
(vlax-release-object obj)
)
Perhaps it is a step more toward the solution... Until now only in Bricscad works, any ideas? :idea:
Thanks,
So you haven't solved the problem. Having to reload the file each time we access a drawing that we've accessed previously in the same session is not an 'ideal' situation.
Thanks again for the time and effort.
; ALE_AddCommand.lsp ; version 1.01 - modified for Bricscad
;
; AutoCAD : need to be reloaded if switch to existing drawing where is already loaded
;
; Bricscad: does not need to be reloaded
;
;
(if (= (getvar "PRODUCT") "Bricscad")
(vlax-add-cmd "tr" 'ALE_TR "tr" 1)
(progn
(vlax-remove-cmd "tr")
(vlax-add-cmd "tr" 'ALE_TR "tr" 1)
)
)
;
(defun ALE_TR ( / obj) ; version 1.00
(setq obj (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (eq 3 (getvar 'CMDACTIVE))
(vla-SendCommand obj "!(ALE_Track \"ACTIVE\")\n")
(vla-SendCommand obj "(ALE_Track nil)\n")
)
(vlax-release-object obj)
)
Thanks,I do not really like reactors but this seems to work (see attachments):
So you haven't solved the problem. Having to reload the file each time we access a drawing that we've accessed previously in the same session is not an 'ideal' situation.
Thanks again for the time and effort.
(and
(/= (getvar "PRODUCT") "Bricscad")
(not #DocumentReactor)
(setq #DocumentReactor
(vlr-docmanager-reactor
nil
'(
(:vlr-documenttobeactivated . ALE_LoadAddCommand)
(:vlr-documenttobedestroyed . ALE_CleanReactor)
)
)
)
)
;
(defun ALE_LoadAddCommand (r d)
; (print ">>Loading ALE_AddCommand<<")
(load "Z:/Temp/ALE_AddCommand.lsp");modify this
(princ)
)
(defun ALE_CleanReactor (r d)
(mapcar 'VLR-remove (list #DocumentReactor))
(setq #DocumentReactor nil)
(princ)
)
I do not really like reactors but this seems to work (see attachments):
Prego! :-) :-) :-)I do not really like reactors but this seems to work (see attachments):
Marc'Antonio,
WOW! I applied your method to my original functions i.e. removing the commands with (vlax-remove-cmd) before redefining them with (vlax-add-cmd) within the ":vlr-documenttobeactivated" reactor and IT WORKS! What I cannot understand is I have tried to employ this previously, but from within the same (mapcar) loop and I caused an error. Apparently it seems to work if the (mapcar) loops are separated.
THANK YOU!!! :-D
...