Results 1 to 8 of 8

Thread: Problem with the result of vlax-get-property

  1. #1
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    Default Problem with the result of vlax-get-property

    I am trying to get the start point of a line object and I used the following code

    (setq start_pt (vlax-get-property obj 'StartPoint))

    but when I (princ start_pt)

    I get "#<variant 8197 ...>"

    Do I need to do anything to the variable to turn it into a point list?

  2. #2
    Member
    Join Date
    2003-10
    Posts
    43
    Login to Give a bone
    0

    Default Re: Problem with the result of vlax-get-property

    Try

    (vlax-variant-value start_pt )

    Dan

  3. #3
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    Default Re: Problem with the result of vlax-get-property

    Dan, when I use that I get an error

    ; error: ActiveX Server returned the error: unknown name:

  4. #4
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Problem with the result of vlax-get-property

    Try this instead
    Code:
    (vl-load-com)
    ....................
    (setq start_pt  (vlax-get obj 'StartPoint))
    (princ start_pt)
    ~'J'~

  5. #5
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Problem with the result of vlax-get-property

    Try
    (setq start_pt (vlax-get Obj 'StartPoint ) )
    or
    (setq start_pt (vlax-get Obj "StartPoint" ) )

    : ) Happy Computing !

    kennet

  6. #6
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    487
    Login to Give a bone
    0

    Default Re: Problem with the result of vlax-get-property

    this testit fuction show how to get the startpoint of a line to a list
    the code well error IFa line, arc or ellipse is not select

    Code:
    (defun c:testit()
    (setq entname (car (entsel)));get entity name
    (setq obj (vlax-ename->vla-object entname));set to a vla-object
    (setq sp (VLA-GET-STARTPOINT obj));get the startpoint this is a variant
    (setq sp2 (vlax-variant-value sp));get the value of the variant this is a safearray
    (setq sp3 (vlax-safearray->list sp2));change the safearray to a list
    ;;the next line dose it in one line
    (setq x (vlax-safearray->list(vlax-variant-value(vla-get-startpoint obj))))
    )
    Last edited by jwanstaett; 2006-08-24 at 12:51 PM.

  7. #7
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    Default Re: Problem with the result of vlax-get-property

    I got it to work with the following code. The finished product is not complete yet but this is a start.

    Code:
    (defun dtr (a)
    (* (/ a 180.00) pi)
       )
    
    
    (defun rtd (a)
      (* (/ a pi) 180.0)
      )
    
    (defun c:bad_pick (/ obj start_pt end_pt length_obj angle_obj midpt)
      	(setq obj (car (entsel "\nSelect Line Object: ")))
      	(setq obj (vlax-ename->vla-object obj))
          	(vl-load-com)
          	(setq start_pt (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'StartPoint))))
      	(setq end_pt (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'EndPoint))))
      	(setq length_obj (vlax-get-property obj 'Length))
          	(setq angle_obj (vlax-get-property obj 'Angle))
    	(setq midpt (polar start_pt angle_obj (/ length_obj 2)))
    
    
    	(setq l_obj (strcat (rtos length_obj 2 2) "\'"))
          	(setq a_obj (angtos angle_obj 4 4))
          	(setq a_obj (vl-string-subst "%%d" "d" a_obj))
          	(command "mtext" midpt "r" (rtd angle_obj) "j" "mc" "w" "0" a_obj l_obj "")
    
    
    (princ)
    )

  8. #8
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Problem with the result of vlax-get-property

    Hi boesiii,
    Since you are using ActiveX for most of your routine, here's the missing part to take the creation of the Mtext from the command function to ActiveX.....
    Code:
          	;(command "mtext" midpt "r" (rtd angle_obj) "j" "mc" "w" "0" a_obj l_obj "")
      (setq *doc* (vla-get-activedocument (vlax-get-acad-object))) 
      (setq mtxt (vlax-invoke
    	       (vla-objectidtoobject *doc* (vla-get-ownerid obj))
    	       'addmtext
    	       midpt
    	       0
    	       (strcat a_obj "\\P" l_obj)
    	       ))
      (vla-put-attachmentpoint mtxt acAttachmentPointMiddleCenter)
      (vlax-put mtxt 'insertionpoint midpt)
      (vla-put-rotation mtxt angle_obj)

Similar Threads

  1. Help with Dynamic Block Vlax-Put-Property
    By jeffmoran in forum AutoLISP
    Replies: 10
    Last Post: 2012-08-23, 05:06 PM
  2. vlax property lists
    By drewj in forum AutoLISP
    Replies: 2
    Last Post: 2011-08-18, 05:54 PM
  3. vlax-put-property
    By jkleinowski in forum AutoLISP
    Replies: 1
    Last Post: 2011-01-21, 04:47 AM
  4. problem with vlax-invoke-method
    By rlash in forum AutoLISP
    Replies: 8
    Last Post: 2010-10-27, 03:01 PM
  5. How to get radius using vlax-get-property?
    By GreyHippo in forum AutoLISP
    Replies: 2
    Last Post: 2006-08-10, 01:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •