Bigal,
您的代码在理论上是可行的,但是由于有这么多310代码,字符串长度变得惊人。我相信有几十万根绳子。如果有人想提高自己,我会把我现在的代码贴在下面。(我的“Hex2RGBA”功能最需要改进)
d2010,
我相信Geomap图像在2014年才发布,所以我不认为我可以发布旧版本。任何可以使用GEO (GEOGRAPHICLOCATION)命令并显示“地理位置”上下文功能区的人都可以创建地理地图图像。
当前代码:
- (defun LM:base->dec ( n b / l )
- (if (= 1 (setq l (strlen n)))
- (- (ascii n) (if (
- (+ (* b (LM:base->dec (substr n 1 (1- l)) b)) (LM:base->dec (substr n l) b))
- )
- )
-
- ;; hex - string, of hexadecimal values (no spaces) to convert to RGBA.
- ;; returns - list, of RGBA values as ((R G B A) (R G B A) ...) or nil if errors detected.
- (defun Hex2RGBA (hex / pos len errMsg rgba return)
- ;; Prep
- (setq pos -1 len (strlen hex))
- ;; Initial Check(s)
- (setq errMsg
- (cond
- ((not (zerop (rem len 8))) "\nHex2RGBA error; Invalid hex string length.")
- );cond
- );setq
- (if errMsg
- (prompt errMsg)
- ;else
- (repeat (/ len 8)
- (setq rgba '())
- (setq return
- (cons
- (reverse
- (repeat 4
- (setq rgba
- (cons
- (LM:base->dec
- (substr hex (setq pos (+ 2 pos)) 2)
- 16
- );LM
- rgba
- );cons
- );setq
- );repeat
- );reverse
- return
- );cons
- );setq
- );repeat
- );if
- (reverse return)
- );defun
-
- (defun Get310s (e / )
- (mapcar
- 'cdr
- (vl-remove-if
- '(lambda (x) (/= 310 (car x)))
- (entget e)
- );vl-remove-if
- );mapcar
- );defun
-
- (defun c:GEOCOPY ( / gmap gc310 hex rgba)
- (prompt "\nSelect Geomap Image: ")
- (if (and (setq gmap (car (nentsel "\nSelect Geomap Image: ")))
- (eq "GEOMAPIMAGE" (cdr (assoc 0 (entget gmap)))))
- (progn
- (setq gc310 (Get310s gmap))
- (setq hex (apply 'strcat gc310))
- (setq rgba (hex2rgba hex))
- ;; Do stuff with RGBA
- (prompt "\nGEOCOPY Complete.")
- );progn
- );if
- (princ)
- );defun
-
最佳,
~DD |