Like Hyperlink

Like Hyperlink

neam
Collaborator Collaborator
1,193 Views
16 Replies
Message 1 of 17

Like Hyperlink

neam
Collaborator
Collaborator

Hi

I have many text(Mtext) in dwg file, I want each text to be linked to a cell in an Excel file. So that by double-clicking on the text, the Excel file will be opened and placed on the desired cell.

Is this possible?

0 Likes
Accepted solutions (1)
1,194 Views
16 Replies
Replies (16)
Message 2 of 17

Sea-Haven
Mentor
Mentor

YES

 

You need to provide more information, when you say linked in what way, just dump selected mtext to excel starting from a cell address ? name of excel and so on.

0 Likes
Message 3 of 17

neam
Collaborator
Collaborator

Thank you for reply

You are absolutely right: just dump selected mtext to excel starting from a cell address.

But it would be great if you could change the text in Excel by changing the text in AutoCAD.

The name of the Excel file and the cell in it must be specified by the user.

Thank you for guiding me.

 

 

 

0 Likes
Message 4 of 17

neam
Collaborator
Collaborator

This is how the work process looks to me:

1-The desired Mtext in AutoCAD to the desired cell in Excel now.

2-Then double-click on the Mtext or edit it in AutoCAD, Change the linked cell file in the first step (or jump to cell)

0 Likes
Message 5 of 17

neam
Collaborator
Collaborator

 

Do you need more information?

0 Likes
Message 6 of 17

jrreid
Advocate
Advocate

Question2 on your MTEXT. 

 

Are they muli-lines of text or just one text string?

 

If one text string, are you opposed to converting them to blocks and then exporting to excel?

 

At that time what you are wanting can be done.

 

JRR.

0 Likes
Message 7 of 17

neam
Collaborator
Collaborator

Hi

it is single text like: abc or 123a or 1400 ................etc

If it helps solve the problem, i have no problem converting the mtext into blocks.

0 Likes
Message 8 of 17

neam
Collaborator
Collaborator

Please note that I want the mtext in AutoCAD to be linked to the cell in an Excel file.

And when I double-click on it, we will jump to the desired cell in Excel.

And when we edit the mtext in AutoCAD, the linked cell in Excel will be updated.

0 Likes
Message 9 of 17

neam
Collaborator
Collaborator

Dear friends: Do you have any comments?

0 Likes
Message 10 of 17

jrreid
Advocate
Advocate

I have tested this several times and I do think it will work for your MTEXT as well.

I have attached a LSP file that I received from Peter Jamtgaard. I will paste his link below.

1. Create a Block with an Attribute and call your Block ROOMNUMBER (I attached one and you can change the name inside the lisp file to what ever you want it to be called. But you must have the block the same name as the lisp inside).

2. Load the ROOMNUMBER.lsp and run the lisp by typing ROOMNUMBER.

3. Select all of your MTEXT (you said they are 1 string of text).

4. Now they are all Attributes.

5. Watch video attached or go to Express Tools and select Blocks Export Attribute Information.

6. This will create a .TXT file name lets say TEST.txt.

7. Open TEST.txt file using Excel File Open.

8. Click Next Next and Finish. You should see all of your MTEXT now Attributes information.

9. Never change the Handle or Blockname or it will break the link.

10. You can edit here if needed.

11. If you did make changes, Save the TEST.txt off and exit out.

12. Use Express Tools and select Blocks Import Attribute Information

13. This should of updated any changes you made in the Excel file.

14. You can use this either way. Update CAD or Excel first.

 

Peter Jamtgaard link:  ROOMNUMBER.lsp

https://forums.augi.com/showthread.php?169530-Replace-text-with-block-and-transfer-value-into-attrib...

 

Video to watch for exporting and importing 

Scroll down to:  How do I import Excel data into AutoCAD?

https://birchlerarroyo.com/autocad/how-do-i-link-attributes-from-autocad-to-excel.html

 

Seems like a lot but it is very quick when you get the initial part started.

 

Hope this helps.

 

JRR.

 

 

Use the ROOMNUMBER.lsp file to convert your MTEXT to ATTRIBUTES. 

0 Likes
Message 11 of 17

neam
Collaborator
Collaborator

thank you very much jrreid

it's very good

BUT please see my attachment 

0 Likes
Message 12 of 17

Sea-Haven
Mentor
Mentor

Just thinking aloud no idea if it will work, to remember the excel cell address or row/col you could add xdata to the mtext, so could have xls file name and row/col. Would run a lisp and would find relevant text and update excel. The other way is used often and that the excel has the object "handle" saved in a column maybe hidden, and gets the object from Autocad and updates. 

 

I did ask a question about get current selection range  from excel  as Vlisp would make this task much easier. 

 

 

0 Likes
Message 13 of 17

neam
Collaborator
Collaborator

Unfortunately, I did not understand much of what you wrote.

I just realized that the solution to my problem is not easy.

Sorry if I was in a hurry.

Thanks again for your attention.

0 Likes
Message 14 of 17

pbejse
Mentor
Mentor
Accepted solution

I can see on your sample drawing that you already considered Datalink, IMO the best link to an external excel file.

 

Use fields value to update the table in CAD and use DATALINKUPDATE to write to excel file.

Below is an example that shows the area value of the polyline as fields

 

pbejse_1-1629525256054.png

 

As the user modify the polyline, the value on the table will update, and then use DATALINKUPDATE.

You can also use attributes as source of course if you want to go that route.

 

Look into this to understand issues and solutions with "Write data to Link" --> Updating user changes to source file 

particularly message 6 of 6

 

HTH

 

0 Likes
Message 15 of 17

neam
Collaborator
Collaborator

Of course, your solution was not exactly what I wanted, but due to the fact that my English is weak and I could not explain it better. 

With this help, I can solve the problem.

Thanks for all the tips in this.

0 Likes
Message 16 of 17

Sea-Haven
Mentor
Mentor

Pbejse has provided a good simple get data out. Get data in is more complex.

 

Explaining more changing a value in excel then have it update in Autocad, every object has a "handle" it is a individual identity name of that object.

(-1 . <Entity name: 692d54b0>) (0 . "LINE") (5 . "A1")

So I picked a line it has a entity name but this changes every time you open the dwg but the "handle" the "A1" is always the same value every time so you would add a column for the "handle"

SeaHaven_2-1629595057891.png

 

So you can read the cell values using the handle and modify in this case the text value. Note it is dwg specific.

 

Note though if you try to combine the 2 not sure if you will get cyclic errors.

 

Message 17 of 17

neam
Collaborator
Collaborator
Thanks and It was an interesting point
0 Likes