Jump to content

Relative paths in an AutoCAD script (.scr)


BtreeTech

Recommended Posts

As I am using LT 2024, have limited programming skills and need to open and close a number of files I am trying to use a script (.scr) file not a lisp or VBA. The script below does some basic cleaning of files exported from GIS and saves the DXFs as DWGs but I would like this to use relative paths (relative to the working file) so I can avoid changing the paths for each project. Is there a way in can set the paths based on the current open file?

_.open "T:\DXF output\Canopies and Boles.dxf" _.Zoom E _.PURGE all * N _.save LT2018 "T:\DXF output\Canopies and Boles.dwg" Y _.close _.open "T:\DXF output\LabelLines.dxf" _.Zoom E _.PURGE all * N _.save LT2018 "T:\DXF output\LabelLines.dwg" Y _.close _.open "T:\DXF output\LabelText.dxf" _.Zoom E _.PURGE all * N _.save LT2018 "T:\DXF output\LabelText.dwg" Y _.close _.open "T:\DXF output\LabelWhiteOuts.dxf" _.Zoom E _.PURGE all * N _.save LT2018 "T:\DXF output\LabelWhiteOuts.dwg" Y _.close _.open "T:\DXF output\RPAs.dxf" _.Zoom E _.PURGE all * N _.save LT2018 "T:\DXF output\RPAs.dwg" Y _.close _.open "T:\DXF output\Tree Markers.dxf" _.Zoom E _.PURGE all * N _.save LT2018 "T:\DXF output\Tree Markers.dwg" Y _.close _.open "T:\DXF output\Zones Boles Canopies.dxf" _.Zoom E _.PURGE all * N _.save LT2018 "T:\DXF output\Zones Boles Canopies.dwg" Y _.close

 

Link to comment
Share on other sites

I think the script line needs the full file path, what I do is have a control where I build up the functions I want, select the files to work on and press 'go'. In the background this creates a temporary script file writing all the details - functions to run, filepaths and so on but now it works I don't need to worry about that.

 

I would recommend this from Lee Mac: https://lee-mac.com/scriptwriter.html - though LT2024 is limited with the LISP / VBA functions it can run, it might work. Very simple, as described you build up the routine and it does the hard work of creating the script file. You can save the basic of the routine for later use on a different sat / same set / edit for something else./

Link to comment
Share on other sites

Another suggestion as you have lisp in LT 24 I would write the script calling a lisp file. You can load a lisp then call it (dxfspecial dwgname)

Possible script

(load "dxfspecial")
(dxfspecial "Canopies and Boles")
(load "dxfspecial")
(dxfspecial "Canopies and Boles2")
(load "dxfspecial")
(dxfspecial "Canopies and Boles3")

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, BtreeTech said:

@Lee Mac Many thanks, I'm still not sure where is the best place to go for help with AutoCAD is

 

For help with the application, I would suggest here at CADTutor; for programming help, I would suggest TheSwamp.org or StackOverflow (though the latter does not have a large CAD community).

  • Like 1
Link to comment
Share on other sites

28 minutes ago, Lee Mac said:

 

For help with the application, I would suggest here at CADTutor; for programming help, I would suggest TheSwamp.org or StackOverflow (though the latter does not have a large CAD community).

 

Kind of missed my favourite online resource there Lee..... (a great repository for LISP snippets to study and learn from)

Link to comment
Share on other sites

Best place to go there are more, forums/autodesk,Augi. But please don't double post at every other forum. It can take a day or two to get a correct answer to your problem. 

 

Always google 1st with "Autocad lisp" on end of search. eg "Extract attributes csv autocad lisp"

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