Jump to content

why does the first one work and not the second?


markv

Recommended Posts

I am currently slamming my head against my desk. I have two routines that replace blocks by name and then changes the visibility to the proper state. The routines use other predefined functions that are not shown. code below.

 

this one works

 
(defun c:REB (/ ENT1 BL1 NWNM OLD ODNM) ;THIS PROGRAM REPLACES SELECTED DUPLEX RECEPTACLE BLOCKS WITH THE PROPER RECEPTACLE BLOCK IN AN ELECTRICAL DRAWING
 (initerr3)
 (command "-insert" "rec.dwg" "0,0" "" "" "")
 (command "erase" "l" "")
 (setq    ENT1
    (ssget "X"
      (list
        (cons 0 "INSERT")
        (cons
          2
          "DR"
        )
      )
    )
 )
(IF (= ENT1 NIL) (C:FPR))
 (setq N (sslength ENT1))
 (setq I 0)
 (repeat N
   (setq BL1 (entget (ssname ENT1 I))
  NM  (cdr (assoc 2 BL1))
   )
   (setq NWNM (cons 2 (strcat "REC")))
   (setq OLD (assoc 2 BL1))
   (entmod (subst NWNM OLD BL1))
   (setq I (1+ I))
 )
 (c:chdr)
 (prin1)
 (reset3)
 ;(command "-purge" "b" "*" "n")
(c:fpr)
)

;----------------------------------------------------------- c:Chdr -----
(defun c:Chdr ()   ;changes visibility to duplex plan receptacle
 (ChangeVisibility "REC" "Duplex Plan")
 (princ)
)

 

this one does not. it will change the block but not the visibilty state. I have checked for typos and everthing is correct on the block names.

 

 
(defun c:RCR (/ ENT1 BL1 NWNM OLD ODNM) ;THIS PROGRAM REPLACES SELECTED Single Ceiling Mounted RECEPTACLE BLOCKS WITH THE PROPER RECEPTACLE BLOCK IN AN ELECTRICAL DRAWING
 (initerr3)
 (command "-insert" "CR.dwg" "0,0" "" "" "")
 (command "erase" "l" "")
 (setq    ENT1
    (ssget "X"
      (list
        (cons 0 "INSERT")
        (cons
          2
          "SRC"
        )
      )
    )
 )
(IF (= ENT1 NIL) (C:DRC))
 (setq N (sslength ENT1))
 (setq I 0)
 (repeat N
   (setq BL1 (entget (ssname ENT1 I))
  NM  (cdr (assoc 2 BL1))
   )
   (setq NWNM (cons 2 (strcat "CR")))
   (setq OLD (assoc 2 BL1))
   (entmod (subst NWNM OLD BL1))
   (setq I (1+ I))
 )
 (c:Chsrc)
 (prin1)
 (reset3)
 ;(command "-purge" "b" "*" "n")
(c:DRC)
)

;----------------------------------------------------------- c:Chsrc -----
(defun c:Chsrc ()   ;changes visibility to Single Ceiling receptacle
 (ChangeVisibility "CR" "Single Ceiling Receptacle")
 (princ)
)

Link to comment
Share on other sites

It's difficult to test this with limited information. Does it work on the block if you just try the visibility portion of the code?

Link to comment
Share on other sites

No it doesnt that is waht is so strange. I have doulble checked my visibilty state names for discrepencies and it all checks out. I can post the entire code but it gets quite long. it is not broken out into tool box routines as would be a lot better.

Link to comment
Share on other sites

Hi markv.

 

You have some kind of functions that are not recognized in our systemthings like :

(c: fpr)

(c: DRC)

and why did you includ the command purge and did not use it

;(command "-purge" "b" "*" "n")

 

So finally nobody can use your codes or check either.

Regards

Tharwat

Link to comment
Share on other sites

Files attached. RCR.lsp is the NON-working routine, REB.lsp is the working one.

You did not upload the blocks.

Link to comment
Share on other sites

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