Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Anonymous
en respuesta a: Anonymous

Complete function with Marker creation:

 

(defun get_coordinates_from_point (point / )
  (setq position_marker_selection (ssget "_X" '((0 . "POSITIONMARKER"))))

  (if position_marker_selection 
    (progn
      (setq marker_entity_name (ssname position_marker_selection 0))
      (setq marker_object (vlax-ename->vla-object marker_entity_name))

      ; Update marker position with provided point
      (setq new_marker_position (vlax-make-safearray vlax-vbDouble '(0 . 2)))
      (vlax-safearray-put-element new_marker_position 0 (car point))
      (vlax-safearray-put-element new_marker_position 1 (car (cdr point)))
      (vlax-put-property marker_object 'Position new_marker_position)

      ; Return a list of lon/lat
      (list 
        (atof (vla-get-Longitude marker_object))
        (atof (vla-get-Latitude marker_object))
      )
    )
    ; Else
    (progn
      ; Create a marker since none exists
      (entmake '(
        (0 . "POSITIONMARKER")
        (5 . "30F")
        (100 . "AcDbEntity")
        (67 . 0)
        (410 . "Model")
        (8 . "0") ; Layer of marker
        (62 . 1)
        (100 . "AcDbGeoPositionMarker")
        (90 . 0)
        (10 0.0 0.0 0.0) ; Position of marker-text
        (40 . 1.0)
        (1 . "")
        (40 . 0.5)
        (290 . 0)
        (280 . 0)
        (290 . 1)
        (101 . "Embedded Object")
        (100 . "AcDbEntity")
        (67 . 0)
        (8 . "0") ; Layer of marker-text
        (62 . 1)
        (100 . "AcDbMText")
        (10 0.0 0.0 0.0) ; Position of marker-text
        (40 . 1.0)
        (41 . 0.0)
        (46 . 0.0)
        (71 . 1)
        (72 . 5)
        (1 . "Coordinate-Reader") ; Text of marker
        (7 . "Standard")
        (210 0.0 0.0 1.0)
        (11 1.0 0.0 0.0)
        (42 . 7.62551)
        (43 . 1.03479)
        (50 . 0.0)
        (73 . 1)
        (44 . 1.0)
      ))
      ; Return value with maker created
      (get_coordinates_from_point point)
    )
  )
)