Jump to content

Recommended Posts

Posted

gday

the fun begins first day back

Im trying to get my head around creating a list then getting the points back. I Kno ive gotten mixed in with append.

which is sorta what im after.

but i would like the x,y,z, points as one, not using car,cdr etc

(DEFUN c:BB ()
 (SETQ PL NIL)
 (while
   (SETQ PT (GETPOINT "/NSELECT POINT: "))
    (SETQ PL (LIST PL PT))
 )
)

As im trying to manly get the last and first point in the instance, but i thought this way would be good for learning as i also need to do one with listing.

 

so how would i place them in the list, and then pull them out?

 

i would like this to happen with a mline

 

(DEFUN c:BB ()
 (SETQ PL NIL)
 (while
   (SETQ PT (GETPOINT "/NSELECT POINT: "))
    (SETQ PL (LIST PL PT))
 )
(Command "mline" pl pl-1 pl-2) : etc
(command "insert" "block" pl 1 1 0)
(command "insert "block" (pl(last point in the list)) 1 1 0)
(princ)
)
)

thanks again for you help

Posted

Use APPEND instead of LIST to create your list of coords. It will add the new points before the existing ones. After all the points are entered, use REVERSE if the list must be ordered as it was entered (meaning the first point is the first in the list)

Posted

Another function for list creation is CONS.

 

(defun c:test(/ pt pl)
 (while(setq pt(getpoint "\nSelect point: "))
   (setq pl(cons pt pl))
   ); end while
 (command "_.mline")(mapcar 'command(reverse pl))(command)
 (mapcar '(lambda(x)(command "_.-insert" "block" "_s" "1" x "0"))pl)
 (princ)
 ); end of c:test

 

Block "block" must exists in drawing.

Posted

TY fuccaro, but with the append , from what i understand.

you need to stracat,car cadr & caddr, x y z,for the cor ever time, to be able to place an object, or is their a way to pull them out as a hole?

 

 

asmi, from what i understand, the mline bit would work and place it any the listed parts.

But also dose it not insert "block" and every point aswell?

Where i only want it for the first point, and the last point.

This is my routine im trying to do.

(defun C:pi ()
 (setvar "cmdecho" 0)
 (setq dn (getstring "\nWhat size Dn : "))
 (setq ps (strcat "dn" dn))
 (command "_layer" "m" ps "c" "yellow" ps "")
 (while(setq pt(getpoint "\nSelect point: "))
   (setq pl(cons pt pl))
   ); end while

 (command "Mline" "j"       "ZERO"  "s"       1       "St"       dn)
      (mapcar 'command(reverse pl))(command)
 (initget 1 "Y N")
 (setq flg (getkword "do you want a flange at each end :"))
 (if (= flg y)
   ((setq fl (strcat "C:/Documents and Settings/urs/My Documents/flanges/" dn ))
     (command "-insert" fl (first point) 1 1 0)
     (command "-insert" fl (last point) 1 1 0)
   )
 )
);end fuction

thanks for you help

Posted
Where i only want it for the first point, and the last point.

 

Change

 

(command "-insert" fl (first point) 1 1 0)
(command "-insert" fl (last point) 1 1 0)

 

to

 

(command "_.-insert" fl "_s" "1" [color="Green"](car pl) [/color]"0")
(command "_.-insert" fl "_s" "1" [color="#008000"](last pl)[/color] "0")

 

CAR -is first member of list, LAST is last member.

Posted

perfect thanks, thats what i need "last", who would think it would of being so simple.

 

(defun C:pi (/ pl dn ps pt flg fl)
 (setvar "cmdecho" 0)
 (setq pl nil)
 (setq dn (getstring "\nWhat size Dn : "))
 (setq ps (strcat "dn" dn))
 (command "_layer" "m" ps "c" "yellow" ps "")
 (while (setq pt (getpoint "\nSelect points: "))
   (setq pl (cons pt pl))
 )                    ; end while

 (command "Mline" "j" "ZERO" "s" 1 "St" dn)
 (mapcar 'command (reverse pl))
 (command)
 (initget 1 "Y N")
 (setq flg (getkword "do you want a flange at each end :"))
 (if (= flg "Y")(
         (setq fl (strcat "C:/Documents and Settings/urs/My Documents/flanges/Flange_dn_" DN "_E_A.dwg"))
     (command "_.-insert" fl "_s" "1" (car pl) "0")
     (command "_.-insert" fl "_s" "1" (last pl) "0")
   )
 );end if
)                    ;end fuction

thanks how it looks now, but it askes for points and makes it a bit hard to place the points, how would i improve this?

 

  (while (setq pt (getpoint "\nSelect points: "))
(command "_polyline" pt)
   (setq pl (cons pt pl))
 )                    ; end while

 

Also

how would i find the angle of the first two points, and the last two

(seqt pt1 (car pl))
(setq pt2  (cadr pl))
(reverse pl)
(setq pt3 (car pl )
(setq pt4 (card pl)
(setq ang1 (angle p1 p2)
(setq ang2 (angle p3 p4)

 

thanks heaps

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...