Author Topic: only once  (Read 3359 times)

0 Members and 1 Guest are viewing this topic.

rude dog

  • Guest
only once
« on: May 29, 2004, 12:01:08 PM »
If you were to draw two lines on the screen and run this small routine
it will only takes out the info needed on the first line choosen
and when you pick the second line it returns back the info from the first line?
Do I have a variable problem here?

Code: [Select]

(defun c:ss (/ p1 pt en e1 es ee)
(command "setvar" "osmode" "0")
(command "setvar" "osmode" "514")
(setq p1 (getpoint "\nselect line"))
(command "setvar" "osmode" "0")
(setq p1 (ssget p1))(setq pt (ssname p1 0)) (setq en (entnext)) (setq e1 (cdr (entget en)))
(princ "\n")
(princ "Start of line in space is @:")
(setq es (cdr (assoc 10 e1)))(princ es)
(princ "\nEnd of line in space is @:")
(setq ee (cdr (assoc 11 e1)))
)
(princ)


SpeedCAD

  • Guest
Re: only once
« Reply #1 on: May 29, 2004, 03:43:23 PM »
Hi...

The error is in line (setq en (entnext)), this take the next line...

Example:
Code: [Select]
(defun c:ss (/ entity p1 p2)
  (setq entity (car (entsel "\nSelect Line: ")))
  (princ "\n")
  (princ "Start of line in space is @:")
  (princ (setq p1 (cdr (assoc 10 (entget entity)))))
  (princ "\nEnd of line in space is @:")
  (setq p2 (cdr (assoc 11 (entget entity))))
) ;_defun

rude dog

  • Guest
only once
« Reply #2 on: May 29, 2004, 04:43:39 PM »
I was looking to pick the line using the osnap nearest <512>
And since I use a SSGET I thought I had to  use  (setq en (entnext))
after reading this on the ACAD help files:

Quote
The entities selected by ssget are main entities, not attributes of blocks or vertices of polylines. You can access the internal structure of these complex entities by walking through the subentities with entnext. Once you obtain a subentity's name, you can operate on it like any other entity.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
only once
« Reply #3 on: May 29, 2004, 06:22:07 PM »
If you want to "step" through the entities in a selection set you would use ssname. For example:
Code: [Select]

(setq ss (ssget)) ; select what you want.
(setq ss0 (ssname ss 0)) ; entity 1 in selection set (zero based index)
(setq es (cdr (assoc 10 ss0))) ; X value
(setq ss1 (ssname ss 1)); entity 2 in selection set


HTH
TheSwamp.org  (serving the CAD community since 2003)

rude dog

  • Guest
only once
« Reply #4 on: June 03, 2004, 07:48:00 PM »
Code: [Select]

(defun c:ss (/ p1 pss pt e1 es ee)
(setvar "cmdecho" 0)
(command "setvar" "osmode" "0")
(command "setvar" "osmode" "514")
(setq p1 (getpoint "\nselect line"))
(command "setvar" "osmode" "0")
(setq pss (ssget p1))(setq pt (ssname pss 0)) (setq e1 (entget pt))
(princ "\n")
(princ "Start of line in space is @:")
(setq es (cdr (assoc 10 e1)))(princ es)
(princ "\nEnd of line in space is @:")
(setq ee (cdr (assoc 11 e1)))
)
(princ)



you were both right.... works fine now thanks for the hand

DEVITG

  • Bull Frog
  • Posts: 479
Re: only once
« Reply #5 on: June 05, 2004, 11:35:21 AM »
Quote from: SpeedCAD
Hi...

The error is in line (setq en (entnext)), this take the next line...

Example:
Code: [Select]
(defun c:ss (/ entity p1 p2)
  (setq entity (car (entsel "\nSelect Line: ")))
  (princ "\n")
  (princ "Start of line in space is @:")
  (princ (setq p1 (cdr (assoc 10 (entget entity)))))
  (princ "\nEnd of line in space is @:")
  (setq p2 (cdr (assoc 11 (entget entity))))
) ;_defun



As I see , it shall be so


(princ  (setq p2 (cdr (assoc 11 (entget entity)))))


If not the p2 value is not shown.
Location @ Córdoba Argentina Using ACAD 2019  at Window 10