Jump to content

Strip xref paths?


chulse

Recommended Posts

I received this from GSA (US govt agency) as part of a larger program to help set files to their standards. This portion doen't seem to work - does not set the path.

I have tested various parts, but can't see where it is failing.

 

If anyone could have a look and tell me if anything looks wrong I would appreciate it. Any suggestions welcome. Thanks

 

; remove xref paths
; select the first block
(progn
(setq blk (tblnext "BLOCK" 1))
; repeat for each block definition in the drawing
(while (/= blk nil)
 ; determine if the block is an xref
 (setq groupcode70 (cdr (assoc 70 blk)))
 ; determine if groupcode70 contains a bitwise 4
 ; this would indicate it is an xref
 (if (= 4 (logand 4 groupcode70))
   (progn
     ; if groupcode70 contains a bitwise 32 it is resolved
     (if (= 32 (logand 32 groupcode70))
       (progn
         ; it is resolved
         ; strip out path if present
         (if(setq xrefname (cdr (assoc 1 blk)))
         (if (wcmatch xrefname "*\\*")
           ; change the old name to the new
           (command ".-xref" "p"
                    (cdr (assoc 2 blk))
                    (strcat (vl-filename-base xrefname)(vl-filename-extension xrefname))
           ) ;end command
         )) ;end if
       ) ;end progn
       (progn) ; xref is unresolved - do not try to change it
     )
   )
   (progn) ; the block is not an xref
 )
 ; select the next block
 (setq blk (tblnext "BLOCK"))
)
);_end progn

Link to comment
Share on other sites

This works for me:

 

(defun c:FOO  (/ path)
 (vl-load-com)
 (vla-startundomark
   (cond (*activeDoc*)
         ((setq *activeDoc*
                 (vla-get-activedocument (vlax-get-acad-object))))))
 (vlax-for x  (vla-get-blocks *activeDoc*)
   (if (and (vlax-property-available-p x 'isxref)
            (= :vlax-true (vla-get-isxref x)))
     (vla-put-path
       x
       (strcat (vl-filename-base (setq path (vla-get-path x)))
               (vl-filename-extension path)))))
 (vla-endundomark *activeDoc*)
 (princ))

 

Edit - If you don't like using Reference Manager, you could apply the vlax-for statement from the above posted code (with a little tweaking) to an ObjectDBX function which would go through all drawings in a particular project directory, making this change (if applicable) to each drawing's "Model" Layout's Block object (assuming your XREF's are in MS?).

 

Hope this helps!

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