Results 1 to 3 of 3

Thread: Out of my depth... why does this routine jump?

  1. #1
    Member
    Join Date
    2015-08
    Location
    Brisbane, Queensland, Australia
    Posts
    13
    Login to Give a bone
    0

    Default Out of my depth... why does this routine jump?

    Hi,

    I wrote a very basic routine that I want to smarten up, but I'm out of my depth with Lisp knowledge.

    I want to be able to set a ucs in 3d space by selecting the following 3 points and setting them to variables:

    1. insertion point of 1st block [ucs origin point]
    2. insertion point of 2nd block (same block, different location in 3d space) [ucs +ve X point]
    3. centre of top of 1st block [ucs +ve Y point]

    Then I would like to use the third point as a start point for an arc that is put between the two block's top centre points.

    My routine is below.

    The crude, badly tabbed lines with comments are mine, the 'normal'-looking lisp bit in the middle is from a bloke named BearDyugin from a CadTutor forum post.

    I'm far to green too come up with lisp code like that (so far).

    When I run it, the first prompt waits for me to select, but upon clicking the insertion point of my first block, it jumps over the selection of the other two points and crashes and burns with the eloquence of a fiery wall of disintegrating fuselage.

    Code:
    (defun C:ZAT (/ osm flag orig orix oriy)
    	;(setvar "clayer" "E-LTNG-MODL-ZONE-VRTX")				;SET CORRECT LAYER AS CURRENT
    
    	(command "._ucs" "_w")							;SET WORLD UCS (IF Z LEVEL CORRECT)
    	;(command "._ucs" "_named" "_restore" "GROUND")				;SET CUSTOM Z LEVEL UCS
    
    	(setvar "SELECTIONCYCLING" -2)
    
     (vl-load-com)
     (setq	osm (getvar 'OSMODE)
    flag	 T
     )
    
     (vl-catch-all-apply
       (function
         (lambda ()
    (setvar 'OSMODE 64)
    (while flag
      (setq	orig (getpoint "\nPick 0,0,0 Point <Exit>:")
      )
      (cond
        ((not orig)
         (setq flag	nil
    	   orig nil
         )
        )
        ((ssget orig) (setq flag nil))
        (t (princ "\nMissed 1st AT Insertion Point"))
      )
    )
         )
       )
     )
    ; orig
    
     (vl-catch-all-apply
       (function
         (lambda ()
    (setvar 'OSMODE 64)
    (while flag
      (setq	orix (getpoint "\nPick +ve X Point <Exit>:")
      )
      (cond
        ((not orix)
         (setq flag	nil
    	   orix nil
         )
        )
        ((ssget orix) (setq flag nil))
        (t (princ "\nMissed 2nd AT Insertion Point"))
      )
    )
         )
       )
     )
    ; orix
    
     (vl-catch-all-apply
       (function
         (lambda ()
    (setvar 'OSMODE 4)
    (while flag
      (setq	oriy (getpoint "\nPick +ve Y Point <Exit>:")
      )
      (cond
        ((not oriy)
         (setq flag	nil
    	   oriy nil
         )
        )
        ((ssget oriy) (setq flag nil))
        (t (princ "\nMissed 1st AT Top Centre Point"))
      )
    )
         )
       )
     )
    ; oriy
    
    	(command "._ucs" "_3" "_none" orig "_none" orix "_none" oriy)		;CREATE TEMPORARY UCS BETWEEN FINIAL BLOCKS
    
    	(command "._arc" oriy "_e" "_cen" pause "_r" "20000")			;SCRIBE ARC BETWEEN FINIAL BLOCKS - PLI
    
    	(command "._ucs" "_w")							;RESET WORLD UCS (IF Z LEVEL CORRECT)
    	;(command "._ucs" "_named" "_restore" "GROUND")				;RESET CUSTOM Z LEVEL UCS
    
    	(command "._regenall")							;REGEN ALL
    
    	(command "._move" "_last" "" "_none" '(0 0 0) "_none" (list 0 0 8) )	;FUDGE-FACTOR MOVE ARC TO TIP OF FINIAL
    
    	(setvar "SELECTIONCYCLING" 2)
    
    (princ)
    )

  2. #2
    Member
    Join Date
    2015-08
    Location
    Brisbane, Queensland, Australia
    Posts
    13
    Login to Give a bone
    0

    Default Re: Out of my depth... why does this routine jump?

    I've stripped the code back, removed the error-checking / exit-routine-at-any-point bits from the 'middle' part.

    I've realised that I need to make a new variable, based on the subtraction of two of the previously picked variables, but can't get it to run.

    Could someone please weigh in on why this won't work?


    Code:
    	(setq newy	(list
    				(car	(- oriy orig))
    				(cadr	(- oriy orig))
    				(caddr	(- oriy orig))
    			)
    	)
    I'm thinking I need to replace 'list' with something else, but I don't even know enough to be dangerous...

  3. #3
    100 Club
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    116
    Login to Give a bone
    0

    Default Re: Out of my depth... why does this routine jump?

    If I'm understanding you correctly, this should give you what you're after;

    Code:
    (setq newy (mapcar '- oriy orig))

Similar Threads

  1. 2017: Screen jump
    By tadthurston725387 in forum AutoCAD Civil 3D - General
    Replies: 6
    Last Post: 2019-04-18, 02:55 PM
  2. Jump to view from sheet
    By 3dway in forum Revit Platform - Wish List
    Replies: 0
    Last Post: 2013-07-28, 01:41 PM
  3. Jump to the right codeline
    By CADfunk MC in forum VBA/COM Interop
    Replies: 2
    Last Post: 2010-02-23, 09:18 AM
  4. CAD Pilot Jump School
    By dwescott in forum CAD Standards
    Replies: 0
    Last Post: 2009-07-16, 06:40 PM
  5. View Depth vs. Depth Clipping???
    By CADBIMManager in forum Revit - Platform
    Replies: 2
    Last Post: 2008-05-27, 12:40 PM

Posting Permissions

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