Recent Posts

Pages: 1 ... 8 9 [10]
91
AutoLISP (Vanilla / Visual) / Re: Input point OR number (user's choice)?
« Last post by qwrtz on January 23, 2021, 09:19:58 PM »
Thanks very much, Tharwat and Lee Mac.  After a lot of head scratching I think I understand at least part of what each of you wrote.

I got my custom command to work using Tharwat's function.  The user has to press Enter instead of the second point, in order to then be able to enter a number to be used for the rotation angle.  I was hoping the user could just enter a number instead of picking a point, as is the case with the built-in Rotate command.  But this is really not much different.

Lee Mac's function does allow entering a number instead of picking a point, without a preliminary Enter.  But I can't seem to use the number as a rotation angle, maybe because it's a text string instead of a real number.  Is that right?  If so, can the text string be converted to a real number?
92
AutoLISP (Vanilla / Visual) / Re: Input point OR number (user's choice)?
« Last post by Lee Mac on January 23, 2021, 05:12:16 PM »
Ordinarily getpoint will interpret numerical input as a displacement from the origin in the direction of the cursor, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. 10
  2. (8.52676 5.2244 0.0)
  3.  
  4. Command: (distance '(0 0) '(8.52676 5.2244))
  5. 10.0

However, if you precede the getpoint prompt with a call to initget supplied with bit 128 to permit arbitrary input, the numerical input will be returned as a literal string, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. nil
  2.  
  3. 4
  4. "4"

Which can be easily tested using the type function, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (initget 128)
  2. (if (setq pnt (getpoint "\nSpecify point or number: "))
  3.     (if (= 'str (type pnt))
  4.         (princ "\nUser entered a number.")
  5.         (princ "\nUser picked a point.")
  6.     )
  7.     (princ "\nUser dismissed the prompt.")
  8. )

However, since bit 128 allows for arbitrary input, you'll probably want to test that the user has actually provided a valid numerical value, e.g.:

Code - Auto/Visual Lisp: [Select]
  1.     (and
  2.         (progn
  3.             (initget 128)
  4.             (setq pnt (getpoint "\nSpecify point or number: "))
  5.         )
  6.         (= 'str (type pnt))
  7.         (not  (distof pnt))
  8.     )
  9.     (princ "\nPlease provide either a point or number.")
  10. )

93
AutoLISP (Vanilla / Visual) / Re: Input point OR number (user's choice)?
« Last post by Tharwat on January 23, 2021, 04:35:31 PM »
Hi
Something like this ?
Code - Auto/Visual Lisp: [Select]
  1. (or (setq p (getpoint "\nSpecify a point or hit enter for < Number > : "))
  2.     (setq n (getreal "\nEnter any real number :"))
  3.     )
  4.  
94
AutoLISP (Vanilla / Visual) / Input point OR number (user's choice)?
« Last post by qwrtz on January 23, 2021, 03:06:42 PM »
A beginner's question:  Is there a way I can prompt the user to either pick a point -OR- enter a floating point number, whichever the user chooses, and accept either input?  And know which type of input was made?  If it's a number, I want to use it as an angle, not as a distance or a coordinate.
95
AutoLISP (Vanilla / Visual) / Replicate Autoconstrain command in AutoLISP
« Last post by jtm2020hyo on January 23, 2021, 02:34:44 PM »

Does someone know if exists any AutoLISP routine to do exactly what _Autoconstrain command does? if yes, please share the link.

Applications:

A simple application is in AutoCAD architecture and MEP, here exist objects has walls and columns, actually us possible use manual constraints but the autoconstrain command do nothing.

 

... And a autoconstrain.LSP could be create then could be recicled for multiple applications in different objects, included in Civil 3D or maybe Advanced Steel.
96
AutoLISP (Vanilla / Visual) / Re: question about region offset
« Last post by ScottMC on January 23, 2021, 02:29:03 PM »
What is the simplest way to flip the region to get it toward the "Z+" direction. Would a "reverse" be able? Like this tool alot!
97
AutoLISP (Vanilla / Visual) / Re: Support file search path
« Last post by ahsattarian on January 23, 2021, 01:13:07 PM »
This may help u  :



Code - Auto/Visual Lisp: [Select]
  1. (defun c:a ()
  2.   (print (acet-pref-supportpath-list))
  3.   (defun sfspli ()
  4.     ;|  http://paracadd.com/lisp/-access-to-the-options-dialog-properties.LSP  |;
  5.     (print (vla-get-supportpath (vla-get-files (vla-get-preferences (vlax-get-acad-object))))) ;|  http://paracadd.com/lisp/SupportPaths.lsp  |;
  6.     (setq str (getenv "ACAD"))
  7.     (setq li nil)
  8.     (setq txt "")
  9.     (setq n (strlen str))
  10.     (setq i 0)
  11.     (repeat n
  12.       (setq i (1+ i))
  13.       (setq let (substr str i 1))
  14.       (cond ((/= (ascii let) 59) (setq txt (strcat txt let))))
  15.       (cond ((= (ascii let) 59) (setq li (append li (list txt))) (setq txt "")))
  16.     )
  17.     (cond ((/= txt "") (setq li (append li (list txt)))))
  18.     (setq k 0)
  19.     (foreach a li
  20.       (setq k (1+ k))
  21.       (princ "\n  ")
  22.       (cond ((< k 10) (princ "0")))
  23.       (princ k)
  24.       (princ "  --->  ")
  25.       (princ a)
  26.     )
  27.   )
  28.   (princ "\n\n >>>>>>>>>>> Before : >>>>>>>>>>> \n")
  29.   (sfspli)
  30.   (setq shl (vla-getinterfaceobject (vlax-get-acad-object) "shell.application"))
  31.   (setq fld (vlax-invoke-method shl 'browseforfolder 0 "Select a folder" 512 ""))
  32.   (setq ad (strcat (vlax-get-property (vlax-get-property fld 'self) 'path) "\\"))
  33.   (setq li1 (cdr (cdr (vl-directory-files ad "*.*" -1))))
  34.   (setq li2 nil)
  35.   (foreach a li1 (setq b (strcat ad a)) (setq li2 (append li2 (list b))))
  36.   (setq li3 (acad_strlsort li2))
  37.   (setq li0 nil)
  38.   (foreach a li (cond ((not (member a li3)) (setq li0 (append li0 (list a))))))
  39.   (setq li li0)
  40.   (setq li4 (reverse li3))
  41.   (foreach a li4 (cond ((not (member a li)) (setq li (append (list a) li)))))
  42.   (setq str "")
  43.   (foreach a li (setq str (strcat str a ";")))
  44.   (setq str (substr str 1 (1- (strlen str))))
  45.   (setenv "ACAD" str)
  46.   (princ "\n\n >>>>>>>>>>> After : >>>>>>>>>>> \n")
  47.   (sfspli)
  48.   (textscr)
  49.   (princ)
  50. )




98
You need to register your external entity data first, so there is an unique identifier for your own XDATA:
Code: [Select]
(regapp "XLayer")After you've registered this name is entered into the APPID symbol table.
99
The Third Dimension / Re: Sketchup
« Last post by Rustabout on January 23, 2021, 12:12:00 PM »
A bit late to the party here but I need to say that Sketchup's support is complete and total garbage. I type this as my paid subscription has just vanished into thin air.... for the SECOND time. F'ing awful!!

Their 'support' will cheer you on as you figure out the issue on your own. Pathetic.

Some Alternatives: Rhino 3D (expensive upfront but a perpetual license) and Blender (Free?!).
100
I've written this, but it doesn't work


Code - Auto/Visual Lisp: [Select]
  1. (defun c:a ()
  2.   (cond ((= (getvar "clayer") "0") (exit)))
  3.   (setq s (tblobjname "layer" "0"))
  4.   (setq en (entget s '("*")))
  5.   (print en)
  6.   (setq app "XLayer")
  7.   (setq code 1003)
  8.   (setq txt (getvar "clayer"))
  9.   (setq en (entget s (list app)))
  10.   (if (assoc -3 en) ;|  #Xdata  |;
  11.     (setq en (subst (list -3 (list app (cons code txt))) (assoc -3 en) en))
  12.     (setq en (append en (list (list -3 (list app (cons code txt))))))
  13.   )
  14.   (entmod en)
  15.   (setq en (entget s '("*")))
  16.   (print en)
  17.   (princ)
  18. )



Would U please help me   ????
Pages: 1 ... 8 9 [10]