Anuncios

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

Anonymous
en respuesta a: CodeDing

Thanks!

 

You helped point me in the right direction..

 

 

If possible, could take a look at my function and tell me if you see any issues with it? It would be much appreciated!

 

(defun get_coordinates_from_point (point)
  (setq marker_entity_name (ssname (ssget "_X" '((0 . "POSITIONMARKER"))) 0))

  (if marker_entity_name 
    (progn
      (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 (cdr point)))
      (vlax-safearray-put-element new_marker_position 1 (car point))

      ; Apply marker position
      (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))
      )
    )
    ; TODO: create a marker if not found
    (prompt "[FATAL] :: No position marker found")
  )
)

 

I'd like to somehow create a position marker if nothing is found... is that possible through LISP without user input?