changing dwg directory

changing dwg directory

DGRL
Advisor Advisor
1,068 Views
5 Replies
Message 1 of 6

changing dwg directory

DGRL
Advisor
Advisor

Dear forum members,

 

Can someone pls help me to customize my routine?
I have a routine that will backup an dwg to another folder but it needs modification.

Now I need to modify this routine to work with Plant 3D

Plant 3D uses different folders to store dwg files in.
With dwgprefix I can get 1 directory ( the one of the current dwg that is open)

Example

 

Main directory structure is --> ( I will only list the directory's I need to read out )

Main path to main directory is D:\P3D TEST\TEST PROJECT

Subfolders in this dir is,
Isometrics --> (does have subdir's)

Orthos --> dwg (does have subdir's)

Plant 3D models (does have subdir's)

 

when you open 1 of the project dwg's and do dwgprefix on this dwg you get this,

D:\P3D TEST\TEST PROJECT\Plant 3D Models\

 

how can I get variables to use in my LSP that will read out the other directory's?

and no there is no possibility to open the other dwg's to get the path
I need to get acces to these dwg's using below code

 

 (setq path (getvar "dwgprefix"))) result is D:\P3D TEST\TEST PROJECT\Plant 3D Models\

From this file I need to change the variable PATH to the other folders

 

I hope I am clear with this

If you need more info please let me know

 

Best regards,

 

 

 

 

 

 

 

 

 

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
Accepted solutions (1)
1,069 Views
5 Replies
Replies (5)
Message 2 of 6

DannyNL
Advisor
Advisor

You can use this to set a root folder variable

 

(setq root (strcat (vl-filename-directory (vl-string-right-trim "\\" (getvar "DWGPREFIX"))) "\\"))

 

0 Likes
Message 3 of 6

DGRL
Advisor
Advisor

Hi @DannyNL

 

Thanks for the answer though it does not fully does what I need

When I open one of the Isometrics the return will be "D:\\P3D TEST\\TEST PROJECT\\Isometric\\Check_A2\\ProdIsos\\"

 

The root is still and will always be D:\\P3D TEST\\TEST PROJECT\\


It depends on what dwg is open

If for example the P&ID is open and not located in an subdir you get

"D:\\P3D TEST\\TEST PROJECT\\PID DWG\\"

 

If an 3D model is open you get (unless located in subfolder)

"D:\\P3D TEST\\TEST PROJECT\\Plant 3D Models\\"

 

Isometrics are always located in subfolders

"D:\\P3D TEST\\TEST PROJECT\\Isometric\\Check_A2\\ProdIsos\\Drawings\\"

 

There are currently 4 different names fgor the isometrics i.e Check_A2 --> Check_A1 ect

 

The root for this will always be D:\\P3D TEST\\TEST PROJECT\\ but changes per project

 

 

I hope I was not too confusing with this

If you need more info please let me know

 

Best regards,

 

 

 

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
Message 4 of 6

DannyNL
Advisor
Advisor
Accepted solution

Yeah, my bad. Sorry.

 

We also have Plant 3D so I should have known. I've included the 4 drawing folders to be recognized in the path and strip those from the DWGPREFIX. This way you will get the root folder of your Plant 3D project no matter what drawing you have open. You can then use the root to get to the other folders you need.

 

Is this what you need? If not let me know.

 

(defun GetP3DRoot (/ GPR_Folder GPR_EndRoot)
   (setq GPR_Folder (strcase (getvar "DWGPREFIX")))
   (if
     (or
         (setq GPR_EndRoot (vl-string-search "PLANT 3D MODELS" GPR_Folder))
         (setq GPR_EndRoot (vl-string-search "PID DWG"         GPR_Folder))
         (setq GPR_EndRoot (vl-string-search "ISOMETRIC"       GPR_Folder))
         (setq GPR_EndRoot (vl-string-search "ORTHOS"          GPR_Folder))
      )        
      (substr GPR_Folder 1 GPR_EndRoot)
   )
)

 

PS. it will only work for Plant 3D drawings. If none of the 4 main folders are found in the path the routine wil return nil. 

0 Likes
Message 5 of 6

DGRL
Advisor
Advisor
Hi @ DannyNL This is what I need and many thanks for this one. I can work with it and modify it for other projects.
If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
Message 6 of 6

DannyNL
Advisor
Advisor

You're welcome, glad I could help Smiley Happy

0 Likes