Jump to content

Recommended Posts

Posted

Could a lisp create a link between 2 text, when edit a text the second one changed related to

 

Im doing by using field but takes long time.

Posted

I didnt get it.

explain plz

Posted

Well, you supply an object reactor with a list of VLA-objects (owners), and the reactor will fire when any of the objects in the list are modified (depending on the callback data).

 

So you could perhaps store the handle of the text objects in their xdata, so that when the object reactor is fired, the program knows which objects are linked.

 

Lee

Posted

Also note that a LISP routine must be loaded in the drawing for the reactors to work properly.

Posted

This is not a lisp answer but:

A simple way to link 2 objects like text is to make the text then make it a block.

Then you can copy that block anywhere and make as many copies as needed. So when you edit one block all the others update.

To edit the text block double click it and the block info dialog box will appear then click ok and the refedit toolbar box will appear. Now double-click the text to edit and when you have finished click the last button on the refedit toolbar to update all of the same blocks in the drawing.

I use this technique a lot for finish notes in my drawings.

Note if you click the red X close button on the refedit toolbar it will disappear and your screen will still be in refedit mode. If this happens just type refedit and the toolbar will reappear.

For a lisp solution you will need to use an object reactor using the vlr-modified,

vlr-openedForModify event and the vlr-copied event.

So basically

The program would ask the user to select the text (or if embedded into a lisp pass the emane to the program.

Then the program would attach the reactor to the object.

The vlr-copied event would be used to attach the reactor to new copies of the text

The vlr-openedForModify would first get the original text (DXF code 1) and save it to a variable

The vlr-modified event would use ssget using the variable from vlr-openedForModify to get all similar text objects then change their text.

The issue I see is if you had 50 similar text objects the vlr-modified event would be fired for each even though it would not change the other text due to the ssget weeding them out. It would be a lot of program execution for nothing. I don’t think it would be to bad depending on the number of text objects it just might take more time to finish with a lot of objects.

Anyone have thoughts on this

Posted

As the OP said "between 2 text" so the option Lee mentioned would be my approach as well.

I suspect the two text objects may not be identical but share some data that needs to be updated.

Posted

Thanks Alan 8)

 

Asos, this will aid you in writing the handles to Object XData, just make a valid Application string (for the "app" argument) to identify the data with.

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] putxdat [b][color=RED]([/color][/b]Obj App Data [b][color=BLUE]/[/color][/b] ent type1 valeur[b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] xtype
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
         [color=Blue][b]vlax-vbInteger[/b][/color] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]1001[/color][/b] [b][color=#009900]1000[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] xval
   [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-variant[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray-fill[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vlax-make-safearray[/color][/b]
         [b][color=Blue]vlax-vbVariant[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] App Data[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]vla-setXData[/color][/b] Obj xtype xval[b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Posted

I think more information is needed

Questions:

Will there ever be more than two text objects?

Will the data in both text objects always be the same or will just parts of the text will be changed?

Is this mtext or single line text?

Posted

I'm assuming just text content, but my method allows for an arbitrary number of text objects to be linked.

Posted

Just for fun and learning let’s discuss the application.

Turning the text into a block then coping that block, as many times as you want is the easiest way to go in my opinion.

I was just trying to figure out why there would be a need to write a program for this.

I would agree it is a great exercise and could be adapted to other uses.

The user types mtext in autocad

Runs the program

Selects the text

Program attached object reactor with vlr-copied and vlr-modified and also writes the handle to objects xdata

User copies original text and vlr-copied is fired and makes a call to the routine that attaches reactor and xdata to new object

Also the xdata routine will have to update the original text object to include the new objects handle and the new object will have to include the original handle.

Now the user edits one of the text objects and vlr-modified is called

The call back for Vlr-modified would get all the handles except the one from the current object then run a routine that would replace the text in all others to match the edited text.

Do you agree so far yes/no?

How would one keep all the other vlr-modified callbacks form being fired?

You could write a comparison function so if the text is the same don’t change it but I think (and I could be wrong) even if you access an object and don’t change it just the action would cause the vlr-modified to be fired and this would cause and infinite loop.

Posted

Good point John :)

 

I agree, using a block is most succinct way to perform this task - but let us say for arguments sake, that the user wants to keep the text as text objects (just to make things interesting! :P).

 

OK, at this point (taking note of your warning) I would be inclined to move away from an Object Reactor and use a Command Reactor - reacting from such commands as "ddedit" for example.

 

I would be inclined to use perhaps the ssgetfirst function to collect the entity in question and extract the xdata, but this may not be the best method.

 

Just my thoughts,

 

Lee

Posted

I think the command reactor is a good call

What about a combo command reactor and object reactor w\ vlr-copied

Object reactor vlr-copied for xdata attachment

Command reactor to make the changes

Throw in a dialog box or command line option to change all linked objects , select objects or exit just for this one to change.

Posted

I have a text and want to show in more than one place

what I doing is copy the text, but when change the text I have to change in each one

To create as a field, its good and i usualy create a field

So I am wandering if there is a lisp to create a field in one step

but there is one trick

when select a text, if its a field, the lisp draw a vertual line to main text

 

Thanx all

 

special thanx for LEE as usual he is the first one replyed

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