Jump to content

Recommended Posts

Posted

I'm very new to lisp, and doesnt have much time to study, Whats the problem with this?

 

(defun c:se (/ ent obj d delta dx dy se)
 (vl-load-com)
 (if (setq ent (entsel "\nSelecione a LINHA: "))
   (progn
     (setq obj (vlax-ename->vla-object (car ent)))
     (setq d (vla-get-delta obj))
     (setq delta (vlax-safearray->list
     (vlax-variant-value d)))
     (setq dx (car delta))
     (setq dy (cdr delta))
     (setq se ( / dy dx))
     (princ se)
     
     )
   )
 )
     

 

I just want the "delta x" and "delta y" values, but, the lisp is returning the values "doubled". How can i fix it?

 

I'm very grateful fr any help. Thanks!!

Posted

Hi,

 

Try:

(setq delta (vlax-get obj 'delta))

Posted

gile, many thanks for your post, but i get the same error. The error is: the list is duplicated, like this : "(-20.0 5.0 0.0)(-20.0 5.0 0.0)"

 

And when i do "(car delta)", it returns : "-20.0-20.0" and "(cdr delta)" returns "5.05.0"

 

How can i fix it?

Posted

This seems to work fine for me? :unsure:

 

(defun c:test (/ ent obj)
 (vl-load-com)

 (while
   (progn
     (setq ent (car (entsel "\nSelect Line: ")))

     (cond (  (eq 'ENAME (type ent))

              (if (vlax-property-available-p
                    (setq obj (vlax-ename->vla-object ent)) 'Delta)

                (print
                  (vlax-safearray->list
                    (vlax-variant-value
                      (vla-get-Delta obj))))

                (princ "\n** Invalid Object **"))))))

 (princ))

Posted

Ahh, bear in mind that princ will print the values to the screen, but then the return of the princ function will be those values that have just been printed.

 

Hence you will need to follow it with perhaps another princ.

Posted
gile, many thanks for your post, but i get the same error. The error is: the list is duplicated, like this : "(-20.0 5.0 0.0)(-20.0 5.0 0.0)"

 

And when i do "(car delta)", it returns : "-20.0-20.0" and "(cdr delta)" returns "5.05.0"

 

How can i fix it?

 

What do you mean by list?

 

That looks to me to be a string, if it is that, use read to converted to list and then use car for the x and cadr for the y values.

 

See if helps.

Posted

This:

 

(defun c:se (/ ent obj d delta dx dy se)
 (vl-load-com)
 (if (setq ent (entsel "\nSelecione a LINHA: "))
   (progn
     (setq obj (vlax-ename->vla-object (car ent)))
     (setq d (vla-get-delta obj))
     (setq delta (vlax-safearray->list
     (vlax-variant-value d)))
     (setq dx (car delta))
     (setq dy (c[color=Red][b]a[/b][/color]dr delta))
     (setq se ( / dy dx))
     (princ se)
     
     )
   )
[color=Red][b](princ)[/b][/color]
 )

Posted

or... simple remove the princ call at all, that way it will return the last value on the command line.

Posted
or... simple remove the princ call at all, that way it will return the last value on the command line.

 

Or that - yes :)

 

BlackAlnet,

 

Just for your own benefit, I recommend you read this article in the Visual LISP Editor help files:

 

 

help snip.png

Posted

@ LEEMAC

 

Your code is elegant as always. I'm still missing on small things, i think it's because my little experience on LISP. Many thanks for your help mate

Posted
Or that - yes :)

 

BlackAlnet,

 

Just for your own benefit, I recommend you read this article in the Visual LISP Editor help files:

 

 

 

Yes, i always goes on this help, but the lacking of examples make it harder to learn.But is trying the best way to learn, isnt it? =)

I'm very grateful for your help. Thanks!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...