Setq path Xref

Setq path Xref

djurk_haas
Advocate Advocate
310 Views
4 Replies
Message 1 of 5

Setq path Xref

djurk_haas
Advocate
Advocate

Hello,

 

I have a lsp code that is show below. Can it be modified that the path is set into an variable?

What I want to achieve is that the path of the existing Xrefs in the drawing wil be changed (there must be an extra folder in the adress eg "..\folder1" must be "..\folder1\folder2").

 

 

 

(defun c:xrefpath nil
 
  (vl-load-com)
  (vlax-for layout (vla-get-layouts
     (vla-get-activedocument (vlax-get-acad-object))
   )
    (vlax-for i (vla-get-block layout)
      (if (and
    (eq (vla-get-ObjectName i) "AcDbBlockReference")
    (vlax-property-available-p i 'Path)
  )
(princ (vla-get-Path i)
)
      )
    )
  )
  (princ)
  )
0 Likes
311 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

....

(princ (setq YourVariableName (vla-get-Path i))

....

Kent Cooper, AIA
0 Likes
Message 3 of 5

djurk_haas
Advocate
Advocate

This stores all the paths of the severaln Xref's (I have mutiple Xref in the drawing) in the variable.

I need each Xref to be changed.

 

The code must be something like this but I can't put it together:

 

 

(repeat (setq i (sslength ss))
(setq ev (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(if
(and

       (setq xname(vla-get-Name i)

       (setd newpath(vla-get-Path i)

 

(command "-xref" "p" xname newpath)

)

 

0 Likes
Message 4 of 5

MrJSmith
Advocate
Advocate

You need to either flesh out what you are attempting to do or show more of the code. Right now you are saving the XREF path and then attempting to change the path to the saved variable, which won't accomplish anything. From your entry post, you talked about adding a folder path to the path. You'd probably need to use the functions strcat & fnsplit1 unless you have all the new paths already hard coded.

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

You have a q flipped up into a d, and some (setq)'s are missing closing right parentheses....

 

Maybe something like [use the correct path expansion]:

 (setq newpath (strcat (vla-get-Path i) "/folder2"))

 

BUT WAIT -- I see that (vla-get-Path) returns not just the path but also includes the drawing file name, including the .dwg filetype ending, so tacking onto the end of that won't do.  It needs to be put inside, before the drawing part.

Kent Cooper, AIA