RBrigido Posted April 27, 2023 Posted April 27, 2023 Hi Lisp Expert, I need a help on my lisp code here. Context: I work as surveyor, everyday the lads goes collect informations on site and bring to me. After process the data, when I open the DWG, every text levels are in a distance of 0.473 and I need click in every object in a different layer, and use the command "SELECTSIMILAR", then I move to the point. I was trying to create a lisp routine that when using the "movetopoint" command, all texts with the configuration "X.XX", "XX.XX" or "XXX.XX" where X is a number, are shifted (offset) from where they are to -0.473, both horizontally and vertically. Without me having to select the reference point. That's the lisp that I create. Quote (defun c:movetopoint (/ ss) (setq ss (ssget "_X" '((0 . "TEXT") (1 . "*?.[0-9]?[0-9],[0-9][0-9],[0-9][0-9]")))) (if ss (progn (command "_.MOVE" ss "" "_non" "_non" '(0.0 0.0 0.0) '(0.473 0.473 0.0)) (princ "\nTexts successfully moved!") ) (princ "\nNo text found.") ) (princ) ) I'm not sure, but I think that the filter isn't good. I tried some different ideas, like: Quote (ssget "_X" '((0 . "TEXT") (1 . "*?.[0-9]?[0-9],[0-9][0-9],[0-9][0-9]"))) Quote (setq sel (ssget "_X" '((0 . "TEXT") (2 . "X.XX,XX.XX,XXX.XX")))) Quote (setq sel (ssget "_X" '((0 . "TEXT") (1 . "*[0-9]*\\.?[0-9]*")))) Quote (ssget "_X" '((0 . "TEXT") (1 . "*.[0-9]?[0-9][.,][0-9][0-9]"))) Can someone help me with that task? Kind regards, Rodrigo Brígido. Quote
Steven P Posted April 27, 2023 Posted April 27, 2023 As a quick idea, IF you can't get the filter to work I am sure I saw a LISP out there somewhere that will check if a string is a number of apha-numerical string. So you could grab all the text and loop through it to check each if they are in the correct format, maybe with a wcmatch or something? or find a checking LISP, remove them from the ss if not suitable and then move the whole lot after Quote
marko_ribar Posted April 27, 2023 Posted April 27, 2023 Not sure, but this : "X.XX", "XX.XX" or "XXX.XX" reminds me to : "#.##", "##.##" or "###.##" Quote
BIGAL Posted April 27, 2023 Posted April 27, 2023 (edited) What software are you using for the import points, should be able to fix the offset there, if CIV3D labels they have massive amount of variations but can be edited. Edited April 27, 2023 by BIGAL 1 Quote
BIGAL Posted April 27, 2023 Posted April 27, 2023 Steven P ;(cond (type ExcelValue) 'INT) (type ExcelValue) 'REAL) (type ExcelValue) 'STR) if str then maybe look for a chr 0-9 1 Quote
RBrigido Posted April 28, 2023 Author Posted April 28, 2023 18 hours ago, marko_ribar said: Not sure, but this : "X.XX", "XX.XX" or "XXX.XX" reminds me to : "#.##", "##.##" or "###.##" Omg, sometimes we focus so much on the trees and forget about the branches. This idea of replacing the X with # worked perfectly. Thank you Quote
RBrigido Posted April 28, 2023 Author Posted April 28, 2023 8 hours ago, BIGAL said: What software are you using for the import points, should be able to fix the offset there, if CIV3D labels they have massive amount of variations but can be edited. In my case, we use Leica/Trimble (R8, R10, R12) data on Liscad, then we import as DXF to combine all files. Liscad haven't the settings to change the text displacement Quote
Steven P Posted April 28, 2023 Posted April 28, 2023 9 hours ago, BIGAL said: Steven P ;(cond (type ExcelValue) 'INT) (type ExcelValue) 'REAL) (type ExcelValue) 'STR) if str then maybe look for a chr 0-9 Yes, if you are selecting text it will all be returned as a string, so need that 2nd check (defun c:test ( / str ) (setq str (cdr (assoc 1 (entget (car (entsel "Select Text")))))) (princ (type str)) ) Quote
BIGAL Posted April 30, 2023 Posted April 30, 2023 (edited) Have you thought about Stringer or Civil Site Design works inside Civ3D or Bricscad. So imports data from total station. Stringer as name implies, strings, makes surfaces etc Edited April 30, 2023 by BIGAL Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.