Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/11/2023 in all areas

  1. (defun c:MyHatch() (setq ss (ssget "X" (list '(0 . "LWPOLYLINE") '(70 . 1)))) (repeat (setq i (sslength ss)) (setq p (ssname ss (setq i (1- i)))) (setq pl (entget p) lay (assoc 8 pl) color (assoc 62 pl) ) (command "_hatch" "s" p "") (setq hatch (entget (entlast)) hatch (subst lay (assoc 8 hatch) hatch) ) (cond (color (setq hatch (append hatch (list color)))) ) (entmod hatch) ) (setq ss nil) ) Just a quick one...
    3 points
  2. Many years ago I tried to draw stereograms (like this: https://en.wikipedia.org/wiki/Autostereogram ). I used to use Lisp for drawing on AutoCAD’s screen, then I saved the resulted image. I remember at that time I was wondering if I could leave-out AutoCAD, to make AutoLisp to write the data directly into a bitmap file. It didn’t work, Lisp can’t write binary. But these days I returned to that (to writing files, not to stereograms). Lisp can’t write binary, but it can write ordinary text files. So after getting the file right, the rest is just a question of conversion. I downloaded a free hex editor (https://mh-nexus.de/en/hxd/). Now: I use Lisp from inside AutoCAD to write the text file. I open it with Notepad, copy/paste the data in the hex editor and from there I save the file with BMP extension. Here are two samples -converted to GIF with Irfanview (https://www.irfanview.com/) just for uploading in the Forum. And here is a Lisp: (defun c:bmp() (setq file (open "C:\\Users\\miklos.fuccaro\\Desktop\\MyBitmap.tXt" "W")) (setq null4 "00 00 00 00") ; file header: (write-line "42 4d" file) ;Magic Bytes (write-line null4 file) ;File size (write-line null4 file) ;Reserved 1+2 (write-line "36 00 00 00" file) ;Data offset ! ; Image header: (write-line "28 00 00 00" file) ;Heder size (write-line "ff 00 00 00" file) ;image width ! (write-line "ff 00 00 00" file) ;image height ! (write-line "01 00" file) ;Color Planes (write-line "10 00" file) ;Bits / Pixel ! (write-line null4 file) ;No compressions (write-line null4 file) ;Image size (write-line null4 file) ;X pix per m (write-line null4 file) ;Y pix / m (write-line null4 file) ;Colors (write-line null4 file) ;Important colors ; Pixel data: ;| ; saturn (setq col1 "08 08" col2 "1d 00" col3 "ff 1c" cx 115 cy 100 rDisc 50 rX 97 rY 14 i 0) (repeat 256 (setq i (1+ i) j 0) (repeat 256 (setq j (1+ j)) (setq dx (- cx j) dy (- cy i) dx (* dx dx) dy (* dy dy)) (setq onDisc (if (< (+ dx dy) (* rDisc rDisc)) 1 nil)) (setq ell (+ (/ (* (- i cy) (- i cy)) (* rY rY 1.0)) (/ (* (- j cX) (- j cX)) (* rX rX 1.0)))) (setq onEllipse (if (equal ell 1 0.4) 1 nil)) (setq str (if onDisc col2 col1)) (cond ((and onEllipse (= str col1)) (setq str col3)) ((and onEllipse (= str col2) (< i cy)) (setq str col3)) ) (write-line str file) ) ) |; ; tree (setq col1 "ff 2d" col2 "e0 03" col3 "00 1c" col4 "c0 09"r1 0.03 r2 0.65 i 256) (repeat 256 (setq i (1- i) j 0) (repeat 256 (setq str (if (< i 200) col1 col4)) (setq j (1+ j)) (setq str (if (< (abs (- j 90)) (* (rem i (+ 45 (/ i 7))) r2)) col2 str)) (setq str (if (< (abs (- j 90)) (* i r1)) col3 str)) (write-line str file) ) ) (close file) (princ "OK") (princ) )
    2 points
  3. Here a the sources (some of ) you so desperatly wanted. I removed the Sabic-titleblock part so you can add your own. Didn't have time yet to replace some of the old vanilla code yet but remember i started coding this long ago and i do actually have to work sometimes and i have many other app's to attend to and i even have a social life so if you have complaints , about the bad coding or so , well , talk to the hand (or my wife , but i wouldn'd recomment that haha) I did try to preserve the saving and loading for the revision tiles though... but i have no time at the moment to rewrite the entire routine. I did edit the error handler for the escape key but left the code at work so i'll post that later. if you have suggestions , or idea's , knock yourself out thanx to guys like Lee and many others i'm a far better programmer by now but so much to do and so little time... gr. Rlx vt-clean.lsp Vt.dcl
    1 point
  4. it may be a bug I fixed a while ago by not first saving text before starting properties dialog. I'll attach latest version I have, it has a few more (undocumented) bells & whistles but in its core its still the same. VT.LSP Note that some functions / buttons will not work because they only function on my company network like button 'serv' in main dialog and also revision in quick menu only works with my company's titleblocks.
    1 point
  5. Yes, my one doesn't line the blocks up with each other but lines them up with a grid spacing which is where the axis comes into it. I assumed that the blocks would be nearly lined up and so lining both to grid will line them up. For example if one is a at Y axis 10.587 and the other at 9.55, set the grid spacing to say, 2.5 and they will both be moved to Y axis value of 10
    1 point
  6. Try this, block2snap (defun c:block2snap ( / SnapStart Xstart Ystart Zstart snap blkset LenSet Ecount Ename Edata InsPt Xins Yins Zins Xround Yround Zround PtRound NewInsData newdata xoffset yoffset zoffset txtsize) (defun *error* ( msg ) (if doc (_EndUndo doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (defun blksnap (val incr base / Snapdist NewNum NuymSteps Rounded NewCoord) (setq Snapdist (- val base) NewNum (/ Snapdist incr) NumSteps (atoi (rtos NewNum 2 0)) Rounded (* NumSteps incr) NewCoord (+ base rounded) ) ) (setq xoffset 0) (setq yoffset 0) (setq zoffset 0) (setq SnapStart (getvar "SNAPBASE")) (setq Xstart (car SnapStart) YStart (cadr SnapStart) ZStart (caddr SnapStart) ) (setq snap 2.5) ;;default snap distance (if (= xsnap nil)(setq xsnap snap)) (if (= ysnap nil)(setq ysnap snap)) (if (= zsnap nil)(setq zsnap 0)) (if (= MWidth nil)(setq MWidth snap)) (setq snap (getreal (strcat "\nEnter x-axis snap spacing (" (rtos xsnap) "): " ) )) (if (/= snap nil)(progn (setq xsnap snap) (setq ysnap snap) )) (setq snap (getreal (strcat "\nEnter y-axis snap spacing (" (rtos ysnap) "): " ) )) (if (/= snap nil)(setq ysnap snap)) (setq zsnap (getreal (strcat "\nEnter z-axis snap spacing (" (rtos zsnap) ")(set to 0 to set Z axis to 0): " ) )) (if (/= zsnap nil)(setq zsnap 0)) (setq blkset (ssget '((0 . "INSERT")))) (setq LenSet (sslength blkSet)) (setq Ecount 0) (repeat LenSet (setq Ename (ssname blkset Ecount) Edata (entget Ename) mycons 10) ;;Cons for entity reference 10 = block coordinates (setq InsPt (cdr (assoc mycons Edata)) Xins (car InsPt) Yins (cadr InsPt) Zins (caddr InsPt) Xround (blksnap Xins xsnap xstart) YRound (blksnap Yins ysnap ystart) ZRound (blksnap Zins ysnap ystart) PtRound (list (+ Xround xoffset) (+ YRound yoffset)) PtRound (list (+ Xround xoffset) (+ YRound yoffset) (+ ZRound zoffset)) NewInsData (cons mycons PtRound) Newdata (subst NewInsdata (assoc mycons Edata) Edata) ) (if (= "INSERT" (cdr (assoc 0 Edata))) (entmod Newdata)) (setq ECount (1+ Ecount)) ) (princ) )
    1 point
  7. @Anh Quan Find attached lisp to test align block-references+while.LSP
    1 point
  8. Did you google ? Why noy look on Microstation forums this is a lisp forum.
    1 point
  9. 1 point
  10. There are built in shortcuts but of course it might differ from the one you're using in AutoCAD. https://www.autodesk.com/shortcuts/revit You can export your shortcuts as an xml file... so when you change your computer, just import that again
    1 point
  11. Yes you can use commands in Revit even though it doesn't have the command line. I use similar keyboard shortcuts in AutoCAD and Revit so I don't get confused. To setup your keyboard shortcuts, go to File pulldown menu then Options. Under options > User Interface, there is a keyboard Shortcuts in the Right Panel. Click "Customized" and input your desired shortcuts Off-topic : A bit off-topic but might interest you. In AutoCAD we use AutoLISP to automate our task. In Revit there;s this thing called Dynamo, a visual programming software... for me, it is easier to use than AutoLisp..
    1 point
×
×
  • Create New...