See the top rated post in this thread. Click here

Results 1 to 4 of 4

Thread: Need some help using if statement to open up drawings

  1. #1
    100 Club
    Join Date
    2012-03
    Posts
    111
    Login to Give a bone
    0

    Default Need some help using if statement to open up drawings

    I have two types of project types. One is "BBV (ADA SK)" & the other type is anything else. I have an if statement that requires two things to be true then it opens up a drawing. If one of those things is not true i want it to open up another drawing. ln7, ln10, ln13, ln16 are all variables that the program reads from an asci file.
    Code:
    (if (AND(= tbck nil)(= ln16 "BBV (ADA SK)"))
       (while
       (progn
       (setq filepath (strcat (getvar "dwgprefix") ln10 "-" ln7 "," " " ln13 " ADA SK.DWG"))(setq filepath nil)
       );end of first progn
       );endwhile
       (progn
         (setq filepath (strcat (getvar "dwgprefix") ln10 " " ln7 " " ln13 " ADA SK.DWG"))(setq filepath nil)
         );end of second ptogn
       
       )
    I've tried a couple of different things to get this to work. I can get the first part to work if i take out the 2nd part but if i leave the whole thing in it doesn't open up the drawing which would be "ln10 "-" ln7 "," " " ln13 " ADA SK.DWG". So basically if the drawing is the "BBV (ADA SK)" project type & tbck is set to nil i want it to open up "ln10 "-" ln7 "," " " ln13 " ADA SK.DWG". If those conditions are not met i want it to open up "ln10 " " ln7 " " ln13 " ADA SK.DWG".
    Last edited by BlackBox; 2017-10-09 at 05:01 PM. Reason: Please use [CODE] Tags

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    1

    Default Re: Need some help using if statement to open up drawings

    Not sure that I understand why you're immediately setting 'filepath' variable to nil after setting it, but that is likely due to your removing code that I'm unaware of (from the larger routine).

    If all you're trying to do is conditionally set the filepath, consider:
    Code:
    (setq filepath (strcat (getvar 'dwgprefix)
    		       ln10
    		       (if (and (= tbck nil) (= ln16 "BBV (ADA SK)"))
    			 (strcat "-" ln7 ", ")
    			 (strcat " " ln7 " ")
    		       )
    		       ln13
    		       " ADA SK.DWG"
    	       )
    )
    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    100 Club
    Join Date
    2012-03
    Posts
    111
    Login to Give a bone
    0

    Default Re: Need some help using if statement to open up drawings

    That's exactly what i wanted. I was going about it all wrong i guess. Basically i wanted either to open the drawing with the comma as part of the address which is "BBV (ADA SK)" or without which would be a another projecttype.This is part of a lisp routine that i did not write. I thought filepath which is a variable was set back to nil as a way of keeping the code clean. It is difficult to post all of the code because this is a part of a three step process that we use to start drawings. I would not expect anyone to go through the 3 lisp routines that we are using & be able to tell what was going on.
    Quote Originally Posted by BlackBox View Post
    Not sure that I understand why you're immediately setting 'filepath' variable to nil after setting it, but that is likely due to your removing code that I'm unaware of (from the larger routine).

    If all you're trying to do is conditionally set the filepath, consider:
    Code:
    (setq filepath (strcat (getvar 'dwgprefix)
                   ln10
                   (if (and (= tbck nil) (= ln16 "BBV (ADA SK)"))
                 (strcat "-" ln7 ", ")
                 (strcat " " ln7 " ")
                   )
                   ln13
                   " ADA SK.DWG"
               )
    )
    Cheers

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: Need some help using if statement to open up drawings

    No worries; I appreciate the thought that went into your question, my not having to read through all of that code, thanks to your identifying of the problem snippet.

    Sometimes more information (and code) is needed; just glad you got it sorted.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Open Drawings Tab
    By Wish List System in forum Revit Structure - Wish List
    Replies: 0
    Last Post: 2012-12-03, 03:51 PM
  2. Replies: 3
    Last Post: 2012-06-17, 09:42 PM
  3. Replies: 2
    Last Post: 2011-04-28, 02:04 AM
  4. Open Drawings
    By JeffClark in forum AutoCAD General
    Replies: 5
    Last Post: 2010-08-10, 03:56 PM
  5. Can't open drawings
    By tammy346 in forum AutoCAD General
    Replies: 2
    Last Post: 2004-09-30, 11:11 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
  •