Recent Posts

Pages: 1 ... 8 9 [10]
91
CAD General / Re: Import/Reset Multileader Styles
« Last post by ronjonp on May 18, 2017, 09:38:43 am »
If you want some help, post a drawing of the new mleader style you're trying use to update your drawings.
92
AutoLISP (Vanilla / Visual) / Re: To have or not to have (quotation mark)
« Last post by ronjonp on May 18, 2017, 09:36:24 am »
Why not use entmake?
Code - Auto/Visual Lisp: [Select]
  1. (defun _maketext (point string width rotation layer)
  2.  (if point
  3.    (entmakex (list '(0 . "TEXT")
  4.    '(100 . "AcDbEntity")
  5.    (cons 8 layer)
  6.    '(100 . "AcDbText")
  7.    (cons 10 (trans point 1 0))
  8.    '(40 . 60.0)
  9.    (cons 1 string)
  10.    (cons 50 rotation)
  11.    (cons 41 width)
  12.    '(72 . 1)
  13.    (cons 11 (trans point 1 0))
  14.    '(73 . 2)
  15.      )
  16.    )
  17.  )
  18. )
  19. ;; (_maketext (getpoint) "Hello World!" 0.75 (angtof "45") "Text")
93
AutoLISP (Vanilla / Visual) / Re: To have or not to have (quotation mark)
« Last post by Grrr1337 on May 18, 2017, 08:27:26 am »
You could error-trap, which is not advised usually:

Code: [Select]
(or
  (not (vl-catch-all-error-p (vl-catch-all-apply 'command '("._text" "justify" "ML" (getpoint "\n\nPick a point: ") 15 0 (strcat "A" "B" "C")))))
  (not (vl-catch-all-error-p (vl-catch-all-apply 'command '("._text" "justify" "ML" (getpoint "\n\nPick a point: ") "15" "0" (strcat "A" "B" "C")))))
)
94
AutoLISP (Vanilla / Visual) / Re: To have or not to have (quotation mark)
« Last post by irneb on May 18, 2017, 07:41:24 am »
Personally speaking, it will be very easily to misapply function definitions from line to line, especially when writing long piece of code.
Personally speaking  ;)  I see no difference between misapplying a function's arguments and the command-line options. In both cases it becomes a lookup in some help documentation to find out what inputs are required and in what order.
95
Input can be taken using getint, getreal, getkword, getpoint functions etc.

Not really, since when you are already prompted and doing "nothing", you can't close the user prompt just like that, and continue.
However its possible to set some flag to T/nil for a given time and then reverse it:
Code - Auto/Visual Lisp: [Select]
  1. ; (setq wait (seconds 10))
  2. ; (> wait (seconds 0)) -> T, then nil
  3. ; (< wait (seconds 0)) -> nil, then T
  4. (defun seconds ( delay / d s )
  5.  (setq d (rtos (getvar 'CDATE) 2 6))
  6.  (setq s
  7.    (+ delay
  8.      (apply '+
  9.        (list
  10.          (* 60 60 (read (substr d 10 2))) ; extract the hours
  11.          (* 60 (read (substr d 12 2))) ; extract the minutes
  12.          (read (substr d 14 2)) ; extract the seconds
  13.        )
  14.      )
  15.    )
  16.  )
  17. )
  18.  
  19. ; (Wait 5) ; will pause user for 5 seconds
  20. (defun Wait ( secs / wt now )
  21.  (setq wt (seconds secs)) (princ (strcat "\nPaused for " (vl-prin1-to-string secs) " seconds."))
  22.  (while (setq flg (> wt (setq now (seconds 0)))) )
  23.  (alert "\nPause ended.")
  24.  (princ)
  25. )
96
AutoLISP (Vanilla / Visual) / Unicode in string
« Last post by dgpuertas on May 18, 2017, 06:20:14 am »

Its possible to put UNICODE characters in a string variable in Autolisp?

I want to use the Word equation editor to write values ​​from autolisp.
This editor uses the math autocorrector through the property "OMathAutoCorrect" and its "Entries"
For example \beta will be β

Code: [Select]
(setq *msw* (vlax-get-or-create-object (vl-registry-read "HKEY_CLASSES_ROOT\\Word.Application\\CurVer")))
(vlax-for ac (vlax-get-property (vlax-get-property *msw* 'OMathAutoCorrect) 'Entries)
(princ (vlax-get-property ac 'Name))(princ " = ")(princ (vlax-get-property ac 'Value))(princ " \n "))

But most of the characters appear as "?" Because (I think) are unicode

 \bet = ?
 \beta =
 \beth = ?
 \Alpha = ?
 \Bar = ?
 \Beta = ?
 \Chi = ?
 \Dd = ?


Is it possible to get that value in a variable to write it in ms word?

Thanks and sorry for my "googletranslator" english

97
AutoLISP (Vanilla / Visual) / Lisp for print frame
« Last post by carmi on May 18, 2017, 05:41:35 am »
Hi my friends...
There are some lisp code for print a frame around the page?
Regards

ps: i remember that i not have Autocad :)
98
AutoLISP (Vanilla / Visual) / Re: To have or not to have (quotation mark)
« Last post by MeasureUp on May 18, 2017, 02:13:09 am »
In this particular case it really doesn't matter. Both do pretty much the same thing. You can see the quotation mark idea as if sending keystrokes to the command-line, while the sending integer values idea "may" send the value directly or it may first convert it to a string in any case. I'm not exactly sure how ACad has implemented this, my guess would be that it converts to text - would make the command line interactions easier to program on their side.

If this is the case, then sending a fractional number may vary from machine to machine. Depending on how many fractional points are set to be displayed. In which case sending a text string becomes more controllable from the code's side. If it's not the case (and ACad actually just sends the number value direct into the command without conversions) then the number idea would be the most accurate.


Of course, just entering such direct constant values isn't very interesting. It's when those values come from some variable when this makes a bit of difference. Do you just send a fraction value direct? Or do you convert it using something like rtos so you can control the accuracy?

Personally I've not bothered too much - it seems to work fine for those cases where I had to use the command line interface (doesn't happen often). I generally prefer using direct function calls instead of sending to command-line anyway (if at all possible), either through such methods as entmake/entmod or through vla. None of this "guessing" what happens, tends to run a LOT faster, and is able to be done through ObjectDBX on non-current DWG files as well.

Thank you so much irneb.
The reason I rose this question was wanted to keep my mind clear when writing codes.
Personally speaking, it will be very easily to misapply function definitions from line to line, especially when writing long piece of code.

The examples here are certainly for this question only and entmake/entmod would be better to apply in code.
Thanks again.
99
AutoLISP (Vanilla / Visual) / Re: Routine doesnt select Open Polylines
« Last post by gile on May 18, 2017, 02:00:33 am »
Hi,

Using the "&" opertaor gives you more control:
Code - Auto/Visual Lisp: [Select]
  1. '((0 . "*POLYLINE")
  2.  (-4 . "<NOT")
  3.  (-4 . "&")
  4.  (70 . 113)    ; (+ 1 16 32 64)
  5.  (-4 . "NOT>")
  6. ))
is equivalent to:
Code - Auto/Visual Lisp: [Select]
  1. '((0 . "*POLYLINE")
  2.  (-4 . "<OR")
  3.  (70 . 0)     ; lwpolyline or simple 2d polyline
  4.  (70 . 2)     ; curve-fit 2d polyline
  5.  (70 . 4)     ; spline-fit 2d polyline
  6.  (70 . 8)     ; 3d polyline
  7.  (70 . 12)    ; spline-fit 3d polyline
  8.  (70 . 128)   ; linetype generation enabled lwpolyline or simple 2d polyline
  9.  (70 . 130)   ; linetype generation enabled curve-fit 2d polyline
  10.  (70 . 132)   ; linetype generation enabled spline-fit 2d polyline
  11.  (70 . 136)   ; linetype generation enabled 3d polyline
  12.  (70 . 140)   ; linetype generation enabled spline-fit 3d polyline
  13.  (-4 . "OR>")
  14. )

The equivalent of:
Code - Auto/Visual Lisp: [Select]
  1. ((0 . "*POLYLINE")
  2.  (-4 . "<OR")
  3.  (70 . 0)     ; lwpolyline or simple 2d polyline
  4.  (70 . 128)   ; linetype generation enabled lwpolyline or simple 2d polyline
  5.  (-4 . "OR>")
  6. )
should be:
Code - Auto/Visual Lisp: [Select]
  1. '((0 . "*POLYLINE")
  2.  (-4 . "<NOT")
  3.  (-4 . "&")
  4.  (70 . 127)  ; (+ 1 2 4 8 16 32 64)
  5.  (-4 . "NOT>")
  6. )
100
Is it possible to wait for user to give input for few seconds and if no input is received, the program proceeds with default value.

Input can be taken using getint, getreal, getkword, getpoint functions etc.

Pages: 1 ... 8 9 [10]