Lisp to change path to border and title block

Lisp to change path to border and title block

PixelThunder
Participant Participant
521 Views
11 Replies
Message 1 of 12

Lisp to change path to border and title block

PixelThunder
Participant
Participant


We’re using Mechanical’s AMTITLE for borders and title blocks. However, we need to change the location of these dwg files, and also have some new border/title files.
 
I’m looking for a user friendly way to replace drawing borders and title blocks in existing drawings, using the new path.
 
I have tried, for instance:
(gencfgset "Gen@Paths@DwgPath" "x:\\new\\path\\to\\border\\")
(gencfgset "Gen@Paths@DwgTitle" "x:\\new\\path\\to\\title\\")
 
The path is shown correctly in the System Editor. However, AMTITLE is still unable to see the dwg files in these locations (the new ones for obvious reasons, but it can’t see the old ones either).
 
Considering that a .dwg contains information about the paths and the files that are accessible, it ought to be possible to manipulate it, changing paths and drawings. Can it be done with a lisp program, and what would it look like?

0 Likes
Accepted solutions (1)
522 Views
11 Replies
Replies (11)
Message 2 of 12

BlackBox_
Advisor
Advisor

You've not posted the gencfgset LISP, so we can't really comment on what it's doing, that is not working. 

 

OOTB, there's Reference Manager - a standalone application that does exactly what you're after, but doesn't allow you to rename existing XREFs, etc (only modify file paths). 

 

LISP can easily do this for active document, or 'push' to multiple documents using ObjectDBX or Core Console + Script (consider -XREF Command as a start). 

 

HTH


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 3 of 12

PixelThunder
Participant
Participant

Thank you.

I don't have much in my LISP so far, only the two gencfgset lines in my original post (with the actual paths to the directories where the dwg's are).

 

Changing the paths and making the desired dwg's accessible for the active document is exactly what I would like to do. How can it be done with LISP?

0 Likes
Message 4 of 12

BlackBox_
Advisor
Advisor

We do not use AMTITLE and you've not posted the code for your gencfgset function (it's not part of LISP OOTB). 

 

Are these Blocks being inserted or XREFed in? 

 

If they're inserted as Blocks, the LISP in this post may help.

 

Can you post a host drawing and an AMTITLE drawing?


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 5 of 12

BlackBox_
Advisor
Advisor

If they're XREFed in, this should swap name & filepath, returns T is successful:

 

(defun _ChangeXrefPath (oldName newName filePath / xref)
  (if
    (and
      (findfile filePath)
      (tblsearch "block" oldName)
      (setq xrefs (vla-get-blocks
                    (vla-get-activedocument (vlax-get-acad-object))
                  )
      )
      (setq xref (vla-item xrefs oldName))
      (= :vlax-true (vla-get-isxref xref))
    )
     (progn
       (vla-put-name xref newName)
       (vla-put-path xref filePath)
       (vla-reload xref)
       T
     )
  )
)

 


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 6 of 12

PixelThunder
Participant
Participant

> you've not posted the code for your gencfgset function (it's not part of LISP OOTB). 

I don't have a function yet. I have simply tried to change the paths with these commands, but it didn't resolve my issue (I used the actual paths, of course):

(gencfgset "Gen@Paths@DwgPath" "x:\\new\\path\\to\\border\\")
(gencfgset "Gen@Paths@DwgTitle" "x:\\new\\path\\to\\title\\")

 

> Are these Blocks being inserted or XREFed in? 

They are inserted using Mechanical's AMTITLE command.

 

The problem is that AMTITLE in old drawings expects borders/title blocks in a certain location and only the file names that were accessible when the drawings were created.
What I am looking for is a user friendly way (preferably a LISP routine) to, in a manner of speaking, redirect AMTITLE to find the borders and title blocks in the new location, when working with old drawings.

0 Likes
Message 7 of 12

BlackBox_
Advisor
Advisor

@PixelThunder wrote:

> you've not posted the code for your gencfgset function (it's not part of LISP OOTB). 

I don't have a function yet. I have simply tried to change the paths with these commands, but it didn't resolve my issue (I used the actual paths, of course):

(gencfgset "Gen@Paths@DwgPath" "x:\\new\\path\\to\\border\\")
(gencfgset "Gen@Paths@DwgTitle" "x:\\new\\path\\to\\title\\")

 

> Are these Blocks being inserted or XREFed in? 

They are inserted using Mechanical's AMTITLE command.

 

The problem is that AMTITLE in old drawings expects borders/title blocks in a certain location and only the file names that were accessible when the drawings were created.
What I am looking for is a user friendly way (preferably a LISP routine) to, in a manner of speaking, redirect AMTITLE to find the borders and title blocks in the new location, when working with old drawings.


Thanks for clarifying; I did not understand that Mechanical meant AutoCAD Mechanical (which I do not use). 

 

The AMTITLE link helped, and I now see that gencfgset is a built-in LISP function for AutoCAD Mechanical. 

 

I would need to install AutoCAD Mechanical (which I can do) and have sample drawings to better help (the sheet with the old borders/title blocks referenced, and the new borders/title blocks). 

 

Perhaps someone adept at AutoCAD Mechanical can jump in, otherwise consider posting in the AutoCAD Mechanical forum, and include a link to this thread. 

 

Cheers


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 8 of 12

PixelThunder
Participant
Participant

Thank you. And my apologies for the unclarity.

 

AutoCAD Mechanical comes with a bunch of default borders and title blocks. And the templates that come with Mechanical each provide a limited selection of the files in the default locations.
The dwg created from a template inherits the template’s paths and selection of files.

 

Our own drawings work the same way. We just use a different location and our own border & title block files. And now we need to change the location of those border/title block files, and add some new ones – and make them accessible to old drawings.

0 Likes
Message 9 of 12

scot-65
Advisor
Advisor
Accepted solution

@PixelThunder 

You seem to have many scenarios to consider.

Start with BlackBox's link.

 

Another method is to keep the original block name (inside the file) and replace the contents with the new block (inside a directory).

(command "INSERT" "OriginalBlkName=NewBlockName" "")(command)

 

2. For this to work you will need to declare a support path to the directory that has the (new) block library and "Move Up" this path in the tree as needed.

All workstations will need a SFSP to the block library directory.

command OPTIONS and make the first tab "Files" current.

 

scot65_0-1752097668551.png

 

The SFSP method is not making the new blocks accessible to the old drawings but rather making the workstation accessible to your block library.

 

Hope this helps.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 10 of 12

PixelThunder
Participant
Participant

@scot-65 wrote:

@PixelThunder 

You seem to have many scenarios to consider.

Start with BlackBox's link.

 

Another method is to keep the original block name (inside the file) and replace the contents with the new block (inside a directory).

(command "INSERT" "OriginalBlkName=NewBlockName" "")(command)


 

Thank you, both. However, while these do replace the border, the border from the dwg-file is inserted as a plain block, including the GENTITLE_xx tags. Sure, I could remove the tags in the dwg files, but it will still make the border a plain block, which has lost its AMTITLE functionality.

 

 


2. For this to work you will need to declare a support path to the directory that has the (new) block library and "Move Up" this path in the tree as needed.

All workstations will need a SFSP to the block library directory.


Sweet! Thank you. This answers part of my problem. Doing this, AMTITLE can find the old file names in the new locations.

 

 


The SFSP method is not making the new blocks accessible to the old drawings but rather making the workstation accessible to your block library.


Precisely. Is there a user friendly way to make the new ones accessible as well?

0 Likes
Message 11 of 12

CGBenner
Community Manager
Community Manager

@PixelThunder 

 

Hello, do you still need help with this question?

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 12 of 12

PixelThunder
Participant
Participant

@CGBenner wrote:

Hello, do you still need help with this question?


Hello. Yes, I still need help. In post #9 part of the answer is posted; how to access borders & title blocks with the old names in a new location. However, However, I still need a user friendly way to make new borders & title blocks accessible for AMTITLE in old drawings.

0 Likes