Recent Posts

Pages: [1] 2 3 ... 10
1
VB(A) / Re: SetBlockTableRecordId issue
« Last post by roy_043 on Today at 12:33:12 PM »
Ah yes, sorry, I must have skipped that part. Your conclusion would then seem correct.
2
AutoLISP (Vanilla / Visual) / Re: solving cubic equation problem...
« Last post by ribarm on Today at 10:47:47 AM »
I think I solved this one...

Code - Auto/Visual Lisp: [Select]
  1. (defun [E]-[C] ( lst / str+ foo k r rr )
  2.  
  3. ;; Command: ([e]-[c] '(2.0 2.0 2.0))
  4. ;; (1.0 -6.0 12.0 -8.0)
  5. ;; Command: ([e]-[c] '(1.0 3.0 5.0))
  6. ;; (1.0 -9.0 23.0 -15.0)
  7. ;; Command: ([e]-[c] '(0.0660769 4.18334 7.50996 18.2577 94.9829))
  8. ;; (1.0 -125.0 3098.0 -24040.0 56056.9 -3600.0)
  9.  
  10.   (defun str+ ( source / prefix rchar )
  11.     (cond
  12.       ( (= source "") "A")
  13.       ( (= (setq prefix (substr source 1 (1- (strlen source)))
  14.                   rchar (substr source (strlen source))
  15.             )
  16.             "Z"
  17.         )
  18.         (strcat (str+ prefix) "A")
  19.       )
  20.       ( (strcat prefix (chr (1+ (ascii rchar)))))
  21.     )
  22.   )
  23.  
  24.   (defun foo ( l n / x xx s f zzzzz k a b )
  25.     (setq s "(defun f ( l / zzzz ) ")
  26.     (setq k 0)
  27.     (repeat n (setq k (1+ k)) (if (= k 1) (setq s (strcat s "(foreach " (progn (if (null x) (setq x (str+ "")) (setq x (str+ x))) x) " l ")) (setq s (strcat s "(foreach " (progn (if (null x) (setq x (str+ "")) (setq x (str+ x))) x) (if (= k 2) (strcat (setq a (strcat " (vl-remove " (progn (if (null xx) (setq xx (str+ "")) (setq xx (str+ xx))) xx))) " l " (setq b ")")) (strcat (setq a (strcat a " (vl-remove " (progn (if (null xx) (setq xx (str+ "")) (setq xx (str+ xx))) xx))) " l " (setq b (strcat b ")"))))))))
  28.     (setq s (strcat s "(setq zzzz (list "))
  29.     (setq xx nil)
  30.     (repeat n (setq s (strcat s (progn (if (null xx) (setq xx (str+ "")) (setq xx (str+ xx))) xx) " ")))
  31.     (setq s (strcat s "))"))
  32.     (setq s (strcat s "(if (not (vl-some '(lambda ( zzz ) (vl-every '(lambda ( yyy ) (vl-position yyy zzz)) zzzz)) zzzzz)) (setq zzzzz (cons zzzz zzzzz)))"))
  33.     (repeat n (setq s (strcat s ") ")))
  34.     (setq s (strcat s ")"))
  35.     (eval (read s))
  36.     (f l)
  37.     zzzzz
  38.   )
  39.  
  40.   (setq k 0)
  41.   (setq lst (mapcar '(lambda ( x ) (cons (setq k (1+ k)) x)) lst))
  42.   (setq k 0)
  43.   (setq rr (cons 1.0 rr))
  44.   (repeat (length lst)
  45.     (setq r (foo (mapcar 'car lst) (setq k (1+ k))))
  46.     (setq r ((if (= (rem k 2) 0) + -) (apply '+ (mapcar '(lambda ( x ) (if (= (length x) 1) (cdr (assoc (car x) lst)) (apply '* (mapcar '(lambda ( y ) (cdr (assoc y lst))) x)))) r))))
  47.     (setq rr (cons r rr))
  48.   )
  49.   (princ (setq rr (reverse rr)))
  50.   (princ)
  51. )
  52.  
3
VB(A) / Re: SetBlockTableRecordId issue
« Last post by RICVBA on Today at 10:21:14 AM »
So I have to first put a blockreference in the wanted cell in order to use it
Can't you do this 'manually'?

Yes I can. And I did, as per last lines of my very same post, which I hereby recall:

"In any case I also tried to first manually put a blockreference in a cell and then use both GetBlockTableRecordI and GetBlockTableRecordI2 methods to retrieve the block Id in that cell, but in both cases Excel crashed silently…"
4
Please upload a sample.dwg
5
When close the file and open again it works
Thanks for all

Perhaps incorporate a call to the command UPDATEFIELD and select the previously created text?
6
 :-Psorry brother , i am not autolisper , i want lisp to this task explained in image  , in frist image explain senario and lisp result with wihte line at red poly line ,
7
AutoLISP (Vanilla / Visual) / Re: REQ: from point draw line with preset length and angle
« Last post by MP on December 12, 2019, 03:03:36 PM »
This appears to be homework. Where is the code you've written so far? What specifically are you struggling with?
8
hello all .
please can you help me to write lisp to do this massion .
lisp sinario explained in images attached
9
AutoLISP (Vanilla / Visual) / Re: solving cubic equation problem...
« Last post by ribarm on December 12, 2019, 01:31:20 PM »
For those that are in the mood of solving mathematical problems...

Quote
(defun decomposemat ( mat ) ; mat - nxn matrix
;; mat = ((1.0 0.0 0.0) (0.0 2.0 0.0) (0.0 0.0 3.0))
;; eigenvalues = 1.0; 2.0; 3.0
;; [E]det = 0; [E]det = (1-x)(2-x)(3-x) = 0
;; (2-x-2x+x^2)*(3-x) = (2-3x+x^2)*(3-x) = 6-2x-9x+3x^2+3x^2-x^3 = -x^3+6x^2-11x+6 = 0
;; (x-1)(x-2)(x-3) = 0 ;; (x^2-2x-x+2)(x-3) = 0 ;; x^3-3x^2-3x^2+9x+2x-6 = 0 ;; x^3-6x^2+11x-6 = 0 ;; -1*[E]det = 0
;; a=1; b=-6; c=11; d=-6 ;; (1.0 -6.0 11.0 -6.0)
;;
;; mat = ((2.0 3.0 8.0)  (1.0 0.0 5.0) (-1.0 5.0 0.0))
;; eigenvalues = -4.19258; 1.19258; 5.0
;; (x+4.19258)(x-1.19258)(x-5.0) = 0 ;; (x^2-1.19258x+4.19258x-5.0)(x-5.0) = 0 ;; (x^2+3x-5)(x-5) = 0 ;; x^3-5x^2+3x^2-15x-5x+25 = 0 ;; x^3-2x^2-20x+25 = 0
;; a=1; b=-2; c=-20; d=25 ;; (1.0 -2.0 -20.0 25.0)
;;
;; mat = ((1.0 2.0) (2.0 1.0))
;; eigenvalues = -1.0; 3.0
;; (x+1)(x-3) = 0 ;; x^2-3x+x-3 = 0 ;; x^2-2x-3 = 0
;; a=1; b=-2; c=-3 ;; (1.0 -2.0 -3.0)
;;
;; mat = ((1.0 3.0 2.0 0.5) (-5.0 7.0 -8.0 6.0) (9.0 12.0 -10.0 11.0) (13.0 -15.0 14.0 -16.0))
;; eigenvalues = -18.4868; -5.79211
;;
;; mat - 4x4 sometimes has also complex numbers eigenvalues
;;
;; mat = ((0.5 0.25 1.5 -2.7 -4.2 3.0 2.4) (1.5 1.25 2.5 -5.7 -1.2 1.0 3.4) (2.5 2.25 0.5 -1.7 -3.2 2.0 4.4) (1.5 3.25 3.5 -4.7 -2.2 4.0 0.4) (3.5 4.25 4.5 -0.7 -0.2 0.0 1.4) (4.5 2.25 1.5 -3.7 -2.2 1.0 3.4) (5.5 5.25 5.5 -0.7 -5.2 5.0 5.4))
;; eigenvalues = -2.14872; 3.80431; 9.59801
;;
;; mat - 7x7 sometimes has also complex numbers eigenvalues
;;
;;
;; mat = ((4.0 2.0 6.0 8.0 2.0) (2.0 10.0 9.0 13.0 7.0) (6.0 9.0 14.0 20.0 12.0) (8.0 13.0 20.0 54.0 35.0) (2.0 7.0 12.0 35.0 43.0))
;; eigenvalues = 0.0660769; 4.18334; 7.50996; 18.2577; 94.9829
;;
;; this mat - 5x5 has only real eigenvalues
;; (x-0.0660769)(x-4.18334)(x-7.50996)(x-18.2577)(x-94.9829) = 0
;; (x^2-4.2494169x+0.276422138)(x^2-25.76766x+137.1145967)(x-94.9829) = 0
;; (x^4-25.76766x^3+137.1145967x^2-4.2494169x^3+109.4975299x^2-582.6570845x+0.276422138x^2-7.122751668x+37.90150997)(x-94.9829) = 0
;; (x^4-30.0170769x^3+246.8885487x^2-589.7798362x+37.90150997)(x-94.9829) = 0
;; x^5-30.0170769x^4+246.8885487x^3-589.7798362x^2+37.90150997x-94.9829x^4+2851.109013x^3-23450.19033x^2+56018.9992x-3599.995331 = 0
;; x^5-125x^4+3098x^3-24040x^2+56056.9x-3600 = 0
;; a=1; b=-125; c=3098; d=-24040; e=56056.9; f=-3600 ;; (1.0 -125.0 3098.0 -24040.0 56056.9 -3600.0)
;;
;; (car rtn) = 1
;; (cadr rtn) = (- (apply '+ eigenvalues))
;; (nth 2 rtn) = (+ (* [E1] [E2]) (* [E1] [E3]) (* [E2] [E3])) - for 3x3;
;; (+ (* [E1] [E2]) (* [E1] [E3]) (* [E1] [E4]) (* [E1] [E5]) (* [E2] [E3]) (* [E2] [E4]) (* [E2] [E5]) (* [E3] [E4]) (* [E3] [E5]) (* [E4] [E5])) - for 5x5
;; (nth 3 rtn) = (- (+ (* [E1] [E2] [E3]) (* [E1] [E2] [E4]) (* [E1] [E2] [E5]) (* [E1] [E3] [E4]) (* [E1] [E3] [E5]) (* [E1] [E4] [E5]) (* [E2] [E3] [E4]) (* [E2] [E3] [E5]) (* [E2] [E4] [E5]) (* [E3] [E4] [E5]))) - for 5x5
;; (nth 4 rtn) = (+ (* [E1] [E2] [E3] [E4]) (* [E1] [E2] [E3] [E5]) (* [E1] [E2] [E4] [E5]) (* [E1] [E3] [E4] [E5]) (* [E2] [E3] [E4] [E5])) - for 5x5
;; ... = ?? - for nxn
;; (last rtn) = (* (* (- (rem (1+ (length mat)) 2) 0.5) 2.0) (apply '* eigenvalues))
10
When close the file and open again it works
Thanks for all
You might check your FIELDEVAL setting too.
Pages: [1] 2 3 ... 10