Move text/objects to specific locations LISP

Move text/objects to specific locations LISP

Anonymous
Not applicable
2,638 Views
11 Replies
Message 1 of 12

Move text/objects to specific locations LISP

Anonymous
Not applicable

Hello everyone, 

 

I am filling out block forms for inventory and on occasion the block that we use has to be altered into a new block. The only issue is that when the block is changed, all the information in the original block is out of order with the new one. I am trying to create a lisp that will move my text to the appropriate areas, based on the changes I made to the block. To make things easier there are two constants: One original block, and one new block that is identical in every way except the labeling, so the dimensions and spacing of the block are the same, just not the name fields. 

 

Attached are some examples, as well as the order in which I would like to translate my text to.

 

In summary, I would like help creating a lisp that will automatically move numbers in the order of the first block, to make the numbers in the second block to go with their correct field after rearranging it. 

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

pbejse
Mentor
Mentor

@Anonymous wrote:

The only issue is that when the block is changed, all the information in the original block is out of order with the new one. I am trying to create a lisp that will move my text to the appropriate areas,

 

In summary, I would like help creating a lisp that will automatically move numbers in the order of the first block, to make the numbers in the second block to go with their correct field after rearranging it. 


Questions:

As you indicated, the lisp is for moving the numbers, Is the block already change before you run the requested lisp? or replacing the block is part of the program? 

 

The numbers are text entity TEXT and not MTEXT or even a mix of both?

 

 

0 Likes
Message 3 of 12

Anonymous
Not applicable
 thanks for the quick response!
 
 In my attachment I have the information of the block (the name, along with a blank field where the user will input information) numbered, so it's easier to see where I need the information the user adds to the original block, translated into the new block. The data in the blank field the user adds in the original block will be MTEXT, then when we go back for inventory the new block is used and replaces the original block (which causes the numbers to be in the wrong spots because some of the labels in the first column are switched around), the numbers need to be moved to the correct spot. The block is already created, I just need to move the MTEXT areas into the right field. So the block is changed before the lisp is ran, then the numbers have to be moved. 
 

 

I hope this helps clarify !

0 Likes
Message 4 of 12

pbejse
Mentor
Mentor

@Anonymous wrote:
So the block is changed before the lisp is ran, then the numbers have to be moved

Ok.

A few more questions:

One block per drawing? On Model space?  The MTEXT objects are on a particular layer? [ for selection filter ]

 

BTW: the image is not the same as the dwg file. Does that mean in the orignal table the order is not always the same?

 

 

 

0 Likes
Message 5 of 12

Sea-Haven
Mentor
Mentor

This is similar to other post about moving attribute order this would be easier than possibly replacing block. I am still looking for that answer.

0 Likes
Message 6 of 12

pbejse
Mentor
Mentor

@Sea-Haven wrote:

This is similar to other post about moving attribute order ...



It doesnt seem to be the case on this one @Sea-Haven, from what i understand from the OP,  the data on the table are MTEXT.

 

It would be an easy fix IF the info given to us is not as confusing as it is now. The drawing file "Original Block.dwg" is showing a different order compared to what is shown on "order of numbers.PNG".

 

ORDER.png

 

Now I'm not sure if the MATERIAL LIST column is fixed at all.  That is why the OP needs to clarify the OLD order for us to proceed.

 

If the MATERIAL LIST column is not part of a block and the order is not the always the same, judging by the MTEXT  alignment, the two columns has two  separate objects per row. 

 

'If words of command are not clear and distinct, if orders are not thoroughly understood, then the general is to blame. ... But, if orders are clear and the soldiers nevertheless disobey, then it is the fault of their oficers.” ― Sun Tzu.

 

 

0 Likes
Message 7 of 12

Anonymous
Not applicable

Hello everyone!

 

Thanks for all the help so far, sorry if it's confusing. This is my very first post on these forums so this is all new to me. As far as the differences in the DWG files that was an error on my part, I uploaded two different versions of the "Original block." The correct version of the Original block is the version that I included as a PNG file that shows both the new and old along with their numbered order. The original block and the new block shown in the PNG files are the only two blocks that will be used, you can disregard the Original block.dwg

0 Likes
Message 8 of 12

Anonymous
Not applicable

It would be one block per sheet, the sheet numbers vary however it's dependent on the size of the project. Also the block is in paper space, with the mtext objects on layer 0 

 

0 Likes
Message 9 of 12

pbejse
Mentor
Mentor

@Anonymous wrote:

It would be one block per sheet, the sheet numbers vary however it's dependent on the size of the project. Also the block is in paper space, with the mtext objects on layer 0 

 


Important to know : what is the block name of the table? 

 

0 Likes
Message 10 of 12

Anonymous
Not applicable

The block's name is "MATERIAL LIST"

0 Likes
Message 11 of 12

pbejse
Mentor
Mentor

For those who are interested on this topic

What we know so far:

1. There are blank rows

2. There are multiple layouts , one target block per layout

3. The values are indeed MTEXT

 

I was able to sucesfully move all values to the correct position, proble i see with this is when some cadee accidentaly run the program again, it will mess up the position. 

 

Preferably, the new block should be in attributes, that way the original MTEXT values will be deleted and the program will find any MTEXT objects in the target scope.

 

Thoughts anyone?

 

 

0 Likes
Message 12 of 12

pbejse
Mentor
Mentor
Accepted solution

One code will work as originally intended, finding the MTEXT within the target scope then moving it to the new location,  [ sample drawing "shifting MultiText" and MLMoveMT.lsp ]

command: MLMoveMT [ use at your own risk ]

 

The other one searches for the MTEXT within the target scope, gather the data, delete the MTEXT then assign the collected values to the attributed block [ sample drawing "shifting_Attributes" and MLMoveATT.lsp ]

command: MLMoveATT

 

@Anonymous  

Please use the  "MATERIAL LIST" block from shifting_Attributes.dwg, and make sure you run ATTYSNC after you redefine a block on your old drawings.

 

HTH

0 Likes