Code Red => AutoLISP (Vanilla / Visual) => Topic started by: autogis on April 06, 2016, 09:01:14 AM
Title: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: autogis on April 06, 2016, 09:01:14 AM
I have many circle objects with text next to them. I need to create a lisp to allow the user to first click on a text object, then click on a circle object and copy the "Contents" from the Text object to the "Hyperlink" of the Circle object. I would like this to be a loop, allowing the user to click on a text, then the circle, then the next text, then the next circle etc until he presses ESC or similar key to end the routine. Any help would be appreciated. Thanks.
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: ChrisCarlson on April 06, 2016, 09:10:37 AM
You'll probably get some more help if you sketch out something in LISP first.
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: autogis on April 06, 2016, 09:20:53 AM
Thanks Buddy I am going to do that right now. I appreciate your advice.
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: autogis on April 06, 2016, 11:34:28 AM
This is what I have so far, but still needs alot of work:
A couple of things that do not work right from the above function: - It should only select one text object and then continue prompting for the circle object - It should not require user to press enter after selecting each object - It does not like to change the "Hyperlink" property of the circle - How do I extract the text property to use it when running the chprop command to save it in the circle's Hyperlink property? - Need the loop to continue until user presses ESC
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: Lee Mac on April 06, 2016, 12:40:21 PM
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: autogis on April 06, 2016, 02:20:00 PM
Thanks, just a quick note for your own information. Since I needed to do an export of the data. When I export with the first version created by Lee, the hyperlink data comes across blank. When I export the data with the second version create by ribarm, the hyperlink contains the data correctly. For this reason I need to use the second version since it allows for correct exporting of hyperlink data. Otherwise as far as functionality works, they both worked the same.
Update: I think I see what it might be. The one that exports correctly, the hyperlink is set as "Existing File or Web Page". The one where the hyperlink does not export is set as "View of This Drawing". Exporting was not part of the original criteria therefore this is just an FYI.
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: autogis on August 25, 2016, 12:04:50 PM
I ran into an issue with the above lisp created by ribarm. If the text object is modified, it is still copying the older data the "hyperlink" property of the text object. The reason being that the older data stays in the "hyperlink" property of the text object. The newly modified text is contained in the "contents" property of the text object. I am trying to figure out how to copy over the "contents" property to the "hyperlink" property to the circle object. I noticed this after someone changed the wording on a text object and the new text was not being copied over to the circle object. Thanks.
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: roy_043 on August 25, 2016, 04:19:37 PM
@autogis: I think you are confused about the functionality of the code in this topic. The hyperlinks that get attached to the circles do not have a link to the text objects.
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: autogis on August 26, 2016, 12:57:29 PM
Roy, thanks for your input. Maybe I did not explain it correctly. I do understand that the hyperlinks do not have a link to the text objects. Perhaps this will help:
1. open autocad, create a text object and a circle object 2. run the lisp created by ribarm above. 3. click the text object, then click the circle object. 4. you will see the hyperlink is set correctly in the circle object. 5. now change the text on the text object 6. run the lisp again 7. click the text object, then click the circle object. 8. this time you will notice that it does not set the text on the circle object to the new text value
Thats basically the issue. I believe the fix is to extract the text from the "contents" property of the text object to get the latest text. That is the issue I am having. Thanks.
Title: Re: How to copy the "Contents" attribute of a Text Object to a Circle Object
Post by: roy_043 on August 26, 2016, 03:53:51 PM
OK, now I understand. :-D Programmatically you can add multiple hyperlinks to an object, but only the first is shown to the user. This explains what you are seeing with Ribarm's code.