乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 68|回复: 1

[编程交流] 插入地理参考图像o

[复制链接]

27

主题

72

帖子

45

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
135
发表于 2022-7-5 19:50:40 | 显示全部楼层 |阅读模式
我们有许多绘图地图的地理参考光栅图像。
 
现在,我们在需要的地方手动将它们插入到图形中。有没有办法,如果我们点击图形中的任何地方,该位置的图像应该被插入。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 20:53:15 | 显示全部楼层
在任何地方插入地理参考jpg,然后使用它,它将移动和重新缩放,但您必须同时拥有JGW文件。
 
  1. ;;;Reads world tiff file (.jgw) to scale and place image correctly in autocad.
  2. ;;;First insert all tiff images into drawing at whatever scale and insertion point.
  3. ;;;If the jgw exists in same directory and is named the same as the image selected,
  4. ;;;it will automatically be found and the image will be scaled and placed. If it is
  5. ;;;not in the same directory, the user can browse for the file.
  6. ;;;03.23.2011 Added support to create jgw files as well as support rotated images
  7. ;;;Needs a file with 6 lines (ScaleX Rotation -Rotation -ScaleY TopLeftXCoord TopLeftYCoord)
  8. ;  « Last Edit: April 12, 2011, 09:43:43 am by ronjonp »  
  9. (vl-load-com)
  10. (defun ss->lst (ss / e n out)
  11.    (setq n -1)
  12.    (while (setq e (ssname ss (setq n (1+ n)))) (setq out (cons (vlax-ename->vla-object e) out)))
  13. )
  14. (defun _writefile (filename lst / file result)
  15.    (cond ((and (eq 'str (type filename)) (setq file (open filename "w")))
  16.    (foreach x lst
  17.      (write-line
  18.        (cond ((= (type x) 'str) x)
  19.       ((= (type x) 'int) (itoa x))
  20.       ((= (type x) 'real) (rtos x 2 6))
  21.       ((vl-prin1-to-string x))
  22.        )
  23.        file
  24.      )
  25.    )
  26.    (close file)
  27.    filename
  28.   )
  29.    )
  30. )
  31. (defun _readfile (filename / file result)
  32.    (cond
  33.      ((and (eq 'str (type filename)) (setq file (open filename "r")))
  34.       (while (setq line (read-line file)) (setq result (cons (vl-string-trim " " line) result)))
  35.       (close file)
  36.       (reverse result)
  37.      )
  38.    )
  39. )
  40. (setq opt "ReadIt")
  41. ;  (initget 0 "ReadIt WriteIt")
  42. ;  (setq opt (cond ((getkword (strcat "\nImage World File [ReadIt/WriteIt] <" opt ">: ")))
  43. ;    (opt)
  44. ;     )
  45. ; )
  46. (princ "\nSelect image(s): ")
  47. (setq pre (getvar 'dwgprefix))
  48. (if (and (setq ss (ssget '((0 . "image")))) (setq ss (ss->lst ss)))
  49.    (foreach image ss
  50.      (setq name    (vlax-get image 'name)
  51.     hgt     (vlax-get image 'height)
  52.     wdth    (vlax-get image 'width)
  53.     imhgt   (vlax-get image 'imageheight)
  54.     imwdth  (vlax-get image 'imagewidth)
  55.     rot     (vlax-get image 'rotation)
  56.     bpt     (vlax-get image 'origin)
  57.     imgpath (vl-filename-directory (vlax-get image 'imagefile))
  58.     jgw     (strcat imgpath "\" name ".jgw")
  59.      )
  60.      (if (= opt "ReadIt")
  61. (progn
  62.   (if (and (or (setq jgw (findfile (strcat pre name ".jgw")))
  63.         (setq jgw (findfile (strcat imgpath "\" name ".jgw")))
  64.         (setq jgw (getfiled (strcat "***Select <<" name ".jgw>>***") pre "jgw" 16))
  65.     )
  66.     (setq pre (strcat (vl-filename-directory jgw) "\"))
  67.     (setq data (mapcar 'atof (_readfile jgw)))
  68.     (> (length data) 5)
  69.     (setq l1 (car data))
  70.     (setq mvpt (list (nth 4 data) (nth 5 data) 0.0))
  71.       )
  72.     (progn (vla-put-imageheight image (* hgt l1))
  73.     (vla-put-imagewidth image (* wdth l1))
  74.     (vla-put-rotation image (cadr data))
  75.     (setq rot (vlax-get image 'rotation))
  76.     (setq bpt (polar bpt (+ (/ pi 2.) rot) (* hgt l1)))
  77.     (vlax-invoke image 'move bpt mvpt)
  78.     (princ (strcat "\njgw File Read - " jgw))
  79.     )
  80.     (princ "\njgw file NOT found or not correctly formatted!")
  81.   )
  82. )
  83. (progn (setq bpt (polar bpt (+ (/ pi 2.) rot) imhgt))
  84.        (if (setq jgw (_writefile
  85.          (strcat imgpath "\" name ".jgw")
  86.          (list (/ imhgt hgt)
  87.         rot
  88.         (strcat "-" (rtos (abs rot) 2 6))
  89.         (strcat "-" (rtos (abs (/ imwdth wdth)) 2 6))
  90.         (rtos (car bpt) 2 6)
  91.         (rtos (cadr bpt) 2 6)
  92.          )
  93.        )
  94.     )
  95. (print jgw)
  96. (princ "\nError writing file...")
  97.        )
  98. )
  99.      )
  100.    )
  101. )
  102. (princ)
  103. (command "draworder" (entlast) "" "B")
  104. ;  « Last Edit: Dec 16 2011 send to back added by alan »
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 01:46 , Processed in 0.398989 second(s), 67 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表