Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Attribute Text Width
« Last post by MeasureUp on Today at 02:02:31 AM »
There is a given attribute named as ATT-01 in a given block BLK-01.
How to change the attribute text width to 0.75?

I did a search here but don't find what I am exactly after.

Thanks in advance.
2
Batch increment prefix and suffix numbers +1 for each click


Code: [Select]
(defun c:XDTB_TxtAddPSuffix ( / e Message Title txt)
  (setq xd-text-prefix-odcl-data '("YWt6A7YgAABCeUbGBuKTJiMVIjtmADAy7RfFuNgkU/zkpPS/mMo3LaUqOtp03BMyM3RU9K4SSAuT"
   "GF1kk5wzUMIWP7pFUYK8ZZGCekG+ZT9vahHCL26Cf/woETq78biJ44NGTbFQGYhKFcg2CEdhsefn"
   "CZiywrGNwBnI0uIhP5OWQS1mR4ekfdExMTBxYrkMep6VAB7tIssGqUaIn25wph1iDfZP/22M4e7F"
   "g/yNjCrhY7rCqvJ787SLfriaQvR8GJtBUcsSCVUUDzKO4tPhaXWkJNPVK8smk1nolT+lDRKl8TQX"
   "IBKY25vmywR8Ze+tr/Svax5FMvpgqgCzkRvAvqgEF9Pk5zhR4uEnOCrBgT/y5CmuKf3v8KCCnZ8V"
   "jcZ7a0VdNUzc9OIdQvBZmgBgO7/PIml7UR5Z2C64Y0yYzMI/f1vm2UMlqRrJK2yC2url07fW8Zcl"
   "AjHdQJOflc2ICsliO9cr6q/pmoLyiIcvrNnjx3F2ATaGA7wBBx3ERJXm2A562DyRp2mHhpEaC8sN"
   "DXiDc4muq6PnlFDhHP2tZrjui1HDqOnJSQRN4rK9zqKbUO/l1CXwzoEQQCBNCGYxtwc3Mur7bliZ"
   "w4gLn9et2cT+951qu3cxt41H5nOKJJGu2sA7hhO8EWyYF1VLaN/0MW8gFjI2iuVQtFzrQTiGR5SR"
   "Ih2w1IYCLKFQhLGqgNn4bSqPUBSBNUxgJaA8SwQelPGyKszgZWuJBzWmjZOyp3uNUNeyBfpJ7+Ho"
   "Q2XHN7IeNvA50xDqmoAwR+GKBsEjpcM2CMhbmxFWQOieGWuh6Z7FaoGWi3UNPSzAKbWRM45wuzn2"
   "rTl3MWzA+U5cAcLnZisJFA1dw8u9ziUvHabe+5NPEhLLFSDQwooubdMMJ6sAL3ak7M5fERx8TR/n"
   "rjKedYs4WFRt5/ewPL48vzzsv6XZngWFCRZfYvCJwdSbX58e3x/Izg76+tjFkmRyBSHuJ0ThJVLC"
   "8+cbbBhTtAtCttfDqqlWH1lNhS3D2cmfY6sM+e1d9C0mHJXN6XFYiBKDCMOAndqhDUTQd5Spj6RV"
   "r7wVCS3B8GmBdKH1iVVg3yvwd6E6gwE4po8ECzHNvQWxNroRMSyd8ZuK1k5+oRFx3X0ABfY44rcR"
   "tZwQFwBlVRgTcNtGfRXinLIsARl3oTHGPubrkBu8cdEPdEuRiemtpOknwvkL3ZHWAhqyJOz7S/3B"
   "qAT3NfBYct1XMIngAIDVeSEGmonnsiQP36S+b1L7heG+mQBvQAkROERNK+gjGKDwcE6tGZwrH1i4"
   "iNUPNxjd7rQ01RJHjLSLce0qKKeWRR4PVoSQJenCUDWgBIjtR4XPIdbwfKRRpnAYQWtKG0FpBZAN"
   "O82clHCeLD0NlVvfcrY4njVTMvW+MwUzldzCtKPcqxtSQwghjFyyKIyOx4RHAtAnkAhJJadomDBF"
   "57RuFO9JGR9WjPiJ7ETTgjKu7skO3nGTaAtUDAoEyVZq9ywI7aT0MuLuDry8d/S9cLUa+WMEafIa"
   "UiLijvpcY1k+cGXBrwww9jzvzvXFHVNdU1kmgROac5I7yW0JCd1oCUkl5mgJvdTPtEZMR1MPWgP5"
   "RNJigekDGCjwrsANNGKqewznQGrLHsy9OtV6IxqoZLqjaEfVseII3dCAgHvqrJ5c"
  )
  )
  (defun c:xd-text-prefix-form#OnInitialize (/)
    (if (not (xd::doc:acadischs))
      (progn (dcl-Control-SetCaption xd-text-prefix-ok "OK")
     (dcl-Control-SetCaption xd-text-prefix-exit "Quit")
     (dcl-Control-SetCaption xd-text-prefix-title "Prefix")
     (dcl-Control-SetCaption xd-text-postfix-title "Suffix")
     (dcl-Control-SetCaption xd-text-prefix-no-title "Start No")
     (dcl-Control-SetTitleBarText xd-text-prefix-form
  "Add Suffixes To Text"
     )
      )
    )
    (if (or (not xd-text-start-no)
    (not (xdrx_string_regexps "^[0-9]+$" xd-text-start-no))
)
      (setq xd-text-start-no "1")
    )
    (dcl-Control-SetText xd-text-prefix-no xd-text-start-no)
    (if (and (= (type xd-text-prefix-value) 'str)
     (setq xd-text-prefix-value (xdrx-string-replace xd-text-prefix-value " " ""))
)
      (dcl-Control-SetText xd-text-prefix-text
   xd-text-prefix-value
      )
    )
    (if (and (= (type xd-text-postfix-value) 'str)
     (setq xd-text-postfix-value (xdrx-string-replace xd-text-postfix-value " " ""))
)
      (dcl-Control-SetText xd-text-postfix-text
   xd-text-postfix-value
      )
    )
  )
  (defun _do-ok ()
    ;(xdrx-begin)
    (while (setq e (car
     (xdrx-entsel (xdrx-string-multilanguage "\n拾取文本字符串<退出>:"
     "\nPick Text String <Exit>:"
  )
  '((0 . "*TEXT"))
     )
   )
   )
      (if (or (xdrx-object-isa e "AcDbText")
      (xdrx-object-isa e "AcDbMText")
  )
(progn (setq txt (xdrx-getpropertyvalue e "textstring"))
       (if (/= xd-text-prefix-value "")
(setq txt (strcat xd-text-prefix-value xd-text-start-no txt))
       )
       (if (/= xd-text-postfix-value "")
(setq txt (strcat txt xd-text-postfix-value xd-text-start-no))
       )
       (if (/= xd-text-start-no "")
(setq xd-text-start-no (itoa (1+ (atoi xd-text-start-no))))
       )
       (xdrx-setpropertyvalue e "textstring" txt)
)
      )
    )
    ;(xdrx-end)
    (princ)
  )
  (defun c:xd-text-prefix-ok#OnClicked (/)
    (setq xd-text-prefix-value (dcl-Control-GetText xd-text-prefix-text)
  xd-text-prefix-value (xdrx-string-replace xd-text-prefix-value " " "")
  xd-text-postfix-value (dcl-Control-GetText xd-text-postfix-text)
  xd-text-start-no (dcl-Control-GetText xd-text-prefix-no)
  xd-text-postfix-value (xdrx-string-replace xd-text-postfix-value " " "")
  xd-text-start-no (xdrx-string-replace xd-text-start-no " " "")
    )
    (if (and (/= xd-text-start-no "")
     (not (xdrx_string_regexps "^[0-9]+$" xd-text-start-no))
)
      (progn (setq Message (xdrx-string-multilanguage "起始序号必须是正整数!"
      "The starting sequence number must be a positive integer!"
   )
   Title   (xdrx-string-multilanguage "XD温馨提示" "XD Warm reminder")
     )
     (dcl-MessageBox Message Title 2)
     (dcl-Control-SetFocus xd-text-prefix-no)
      )
      (progn
(if (and (= xd-text-prefix-value "")
(= xd-text-postfix-value "")
    )
  (progn (setq Message (xdrx-string-multilanguage "前后缀不能同时为空字符串!"
  "The prefix and suffix cannot be empty strings at the same time!"
       )
       Title   (xdrx-string-multilanguage "XD温馨提示" "XD Warm reminder")
)
(dcl-MessageBox Message Title 2)
(if (= xd-text-prefix-value "")
   (dcl-Control-SetFocus xd-text-prefix-text)
   (dcl-Control-SetFocus xd-text-postfix-text)
)
  )
  (progn (dcl-form-close xd-text-prefix-form) (_do-ok))
)
      )
    )
  )
  (defun c:xd-text-prefix-exit#OnClicked (/)
    (dcl-form-close xd-text-prefix-form)
  )
  (dcl_project_import xd-text-prefix-odcl-data)
  (dcl-Form-Show xd-text-prefix-form)
  (princ)
)
3
AutoLISP (Vanilla / Visual) / Re: remove all comments
« Last post by kdub_nz on March 28, 2024, 09:49:43 PM »
When I first started using lisp, I’d have a version with comments and extra whitespace in the code removed, thinking it would run faster.
. . .  :lol:

and you believed in the Easter bunny too ?
4
AutoLISP (Vanilla / Visual) / Re: remove all comments
« Last post by BIGAL on March 28, 2024, 08:32:58 PM »
Bit like on another forum a poster uses tabs and indents code problem is it pushes so far to right code disappears. I try to use 2 spaces rather than tab. Again use \t in search.

It would be pretty easy if comments are always to right -> end of line single lines, to write a lisp using Vl-position and substr writing to a temp file, option delete original or put some where else, then rename back to original.
5
AutoLISP (Vanilla / Visual) / Re: vlax-get-or-create-object
« Last post by BIGAL on March 28, 2024, 08:27:33 PM »
"multiple sheets" You could make a csv that is multiple sheets by having the sheet name as a 1st line Seperator, I use a Lee-mac function to split the csv line to a list so if the list has say a certain name as the only entry on a line then its a new work sheet. Ok so how good are your VBA skills ? Use a Excel macro to write the csv rather than "Save as csv". I am sure if you Google that is your home work there will be a macro to make CSV.

hint https://www.excel-easy.com/vba/examples/write-data-to-text-file.html
6
AutoLISP (Vanilla / Visual) / Re: remove all comments
« Last post by It's Alive! on March 28, 2024, 07:36:51 PM »
When I first started using lisp, I’d have a version with comments and extra whitespace in the code removed, thinking it would run faster.
I was like compiling bro :lol:
7
AutoLISP (Vanilla / Visual) / Re: remove all comments
« Last post by kdub_nz on March 28, 2024, 06:59:35 PM »
. . . and inline comments

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (setq painInTheButt ;|some note here|; (getvar "petPeeves"))
  3.  
  4.  
8
AutoLISP (Vanilla / Visual) / Re: remove all comments
« Last post by Lee Mac on March 28, 2024, 06:42:14 PM »
is there any utility to remove all comments in a large lsp file?

Notepad++
CTRL+H
Find what: ";.*"
Replace with: empty string ""
Replace all

Consider semi-colons in string literals, and multiline comments.
9
AutoLISP (Vanilla / Visual) / Re: remove all comments
« Last post by JohnK on March 28, 2024, 06:24:27 PM »
Not sure why you'd want to do this but your text editor should be able to do this as Lastknownuser pointed out.

I had one in .EXE, but it doesn't run (1991) lol
Id bet common lispers have one

Just made one in C. Reads a directory of files and outputs to a new file while skipping all comment lines.
10
In a dwg file, there are many points and a polyline. I would like to get the points that are within a certain distance from the polyline.

Currently, I have considered the following solutions:

1.Using a global traversal can definitely solve the problem, but the efficiency is too low.

2.Another method is to use the offset function to obtain a closed area and then use ssget for filtering. However, this method may not work well when the polyline shape is complex.

Can algorithms like quadtree be used to achieve this purpose?

n points, one polyline?

Then if you traverse the points globally and obtain the points within the tolerance range, the time complexity of the algorithm is n. How come it is inefficient?
Pages: [1] 2 3 ... 10