Recent Posts

Pages: 1 2 [3] 4 5 ... 10
Challenges / Re: [challenge] A17 : Rotate a list N places to the left
« Last post by dexus on January 25, 2022, 08:39:01 AM »
Took the lazy way of handling negative numbers :embarrassed2:
And my result for 77 is (F G H A B C D E), I think the one in the example is incorrect.
Changed it so the 77 gets recognized as an incorrect input instead of rotating it 77 times.
Code - Auto/Visual Lisp: [Select]
  1. (defun rotate-dexus (l i)
  2.   (cond
  3.     ((> (abs i) (length l)) l)
  4.     ((> i 0) (rotate-dexus (append (cdr l) (list (car l))) (1- i)))
  5.     ((< i 0) (rotate-dexus l (+ i (length l))))
  6.     (t l)
  7.   )
  8. )
Challenges / [challenge] A17 : Rotate a list N places to the left
« Last post by JohnK on January 25, 2022, 07:58:49 AM »
Using only AutoLisp, rotate a list N places to the left.

(rotate '(a b c d e f g h) 3)
> (D E F G H A B C)

(rotate '(a b c d e f g h) -2)
> (G H A B C D E F)

(rotate '(a b c d e f g h) 77)
> (A B C D E F G H)

(rotate '(a b c d e f g h) 0)
> (A B C D E F G H)

(rotate '(a b c d e f g h) nil)
> ; error: bad argument type: numberp: nil
AutoLISP (Vanilla / Visual) / Re: Should I continue with the challenges
« Last post by It's Alive! on January 25, 2022, 06:56:10 AM »
I had an email that was hacked once, someone stole my clash of clans base
Challenges / Re: [challenge] A01 : Find the last element of a list.
« Last post by Marc'Antonio Alessi on January 25, 2022, 06:01:45 AM »
Code: [Select]
(defun ALE_Last6 (L / o) ; for big list, VERY similar to dexus "while-cond-last-plus"
  (while L
    (setq L
        ( (cddddr (cddddr (cddddr (cddddr (cddddr L))))) )
        ( (cddddr L) )
        ( (cdr    L) )
        ( (setq o (car L)  L nil) )
Thank you all for your replies. Your answers let me get it to do what I asked it to do..

But there is a small problem. The attribute text is middle left justified which works if you bring it in on the right (you can have 32A, 20A D-CURVE, REFER NOTE 1 whatever and the text flows out to the right). Usually we mirror the block to get it on to the left hand side of the bus bar and the middle left justified text becomes middle right justified (which is how I want it to be on the left hand side).
Now that I use the lisp to bring in the block with a -ve X value to mirror the block the att text still remains MR justified.

It turns out that It'll work better if I mirror the last block from right to left, not bring it with a -ve scale factor.  :x :x :x poor thinking/wording on my part.

I guess if I do an ENTGET on the assoc numbers of the block when it comes in on the right I can then use the MIRROR command on the last object with two points (original xy and original x&y+100) and it'll work to flip it to the left (and the attribute text will be MR justified).

I guess the other way is to fiddle with the mirrored block on the left and justify it's attribute text to middle right. That seems more complicated to me than a simple mirror command.

Big Al -
I'm always interested to learn. ATM I've got about 60 lisps for about 12 blocks (diff visibility states) which I'm happy with.
Maybe there is a more elegant way to do it. Does your lisp (via LM) recognize a variable (say rotation) and then adjust the vis state to accommodate it?
VB(A) / Re: A new CAD for Linux
« Last post by jtm2020hyo on January 24, 2022, 07:52:14 PM »
Looks awesome.

could share some videos comparing with AutoCAD/Revit/others
I would at least have thought there would be access to database sysvars, like  textstyle,  tablestyle
Setting layers is a database operation, seems like there would be access to that as well.. analog to opening side databases in ARX.
No partying with the document or editor
AutoLISP (Vanilla / Visual) / Re: Create A New Drawing & Save Without Opening it
« Last post by BIGAL on January 24, 2022, 06:13:45 PM »
Like baitang36 look into accoreconsole uses lisp etc should be able to set current layer.
Thanks to Lee,  for a dynamic block you can get all the visibility states of the block, so I pass those to my Library Multi radio buttons.lsp so this allows the choice of which visibility state as part of the insertion routine. This is very handy in some situations where the visibility is constantly changing for each insertion.

Just ask if you want the code.
AutoLISP (Vanilla / Visual) / Re: Create A New Drawing & Save Without Opening it
« Last post by MSTG007 on January 24, 2022, 05:15:43 PM »
Interesting.... Thanks for sharing that Lee. I thought you could do some layer control.
Pages: 1 2 [3] 4 5 ... 10