Author Topic: Setting variables in a file opened by a routine?  (Read 4630 times)

0 Members and 1 Guest are viewing this topic.

Brick_top

  • Guest
Setting variables in a file opened by a routine?
« on: November 23, 2011, 06:48:33 AM »
Hi there,

I would like to set new variables in a file I open with a routine.

I know I can "copy" variables from a drawing to another using vl-propagate. But how do I create new ones?

And how do I propagate more than one variable? vl-propagate only seems to propagate one variable?

thanks.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Setting variables in a file opened by a routine?
« Reply #1 on: November 23, 2011, 06:56:11 AM »
Code: [Select]
(setq a 1
      b 2
      c 3
)
(mapcar (function vl-propagate) '(a b c))

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #2 on: November 23, 2011, 06:56:50 AM »
Nice! thanks a lot!

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Setting variables in a file opened by a routine?
« Reply #3 on: November 23, 2011, 07:05:52 AM »
Code: [Select]
(foreach sym '(a b c) (vl-propagate sym))

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #4 on: November 23, 2011, 07:15:01 AM »
how about the other question? in case I explained my self correctly

thanks for the alternative lee


Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Setting variables in a file opened by a routine?
« Reply #5 on: November 23, 2011, 07:15:58 AM »
Creating a new variable:

Code: [Select]
(setq a 1)

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #6 on: November 23, 2011, 07:18:26 AM »
lets see if I can explain my self better.

I have a routine I run in a drawing.

That routine opens another drawing, and now I want to set new variables in that drawing.


Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Setting variables in a file opened by a routine?
« Reply #7 on: November 23, 2011, 07:24:22 AM »
That routine opens another drawing, and now I want to set new variables in that drawing.

Set the variables in the active drawing and propagate them?

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Setting variables in a file opened by a routine?
« Reply #8 on: November 23, 2011, 07:58:00 AM »
If you do not have a large amount of data you can use the setenv/getenv

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #9 on: November 23, 2011, 08:58:46 AM »
That routine opens another drawing, and now I want to set new variables in that drawing.

Set the variables in the active drawing and propagate them?

Well in the way I'm seeing things right now I don't know how to do that because of what I want to do because there are variables that need to be set differently in the "other" drawing.

What I want to do is save notes in each drawing (as xrecords) I have and then have a "master" drawing with all the notes so I can later search all the notes of all the projects. Problem is the xrecord "name?" is diferent in the master drawing.

For example I name the notes in all the projects as "Note 1" "Note 2" "Note 3" etc.. every project will start in number 1. But the "master" drawing where I'll have all the notes stored will only have one "Note 1".





« Last Edit: November 23, 2011, 09:02:30 AM by Brick_top »

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #10 on: November 23, 2011, 09:03:18 AM »
I need to check the xrecords in the "opened by the routine" file to set the new name of the next xrecord.

At least this is what I'm thinking

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #11 on: November 23, 2011, 09:08:12 AM »
This is what I'm doing to check the number of the note, and set the number of the next one.

Code: [Select]
(setq a (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 3 (car x)))(entget (namedobjdict))))
         b (vl-remove-if-not '(lambda (x) (= "Nota" (substr x 1 4))) a)
         titl2 (strcat "Nota" " " (itoa (+ 1 (length b))))
   );setq

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #12 on: November 25, 2011, 04:49:23 AM »
I gave up the ideia, I just run another routine in the opened file to set the new variables.

FreeBird

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #13 on: November 27, 2011, 06:10:12 AM »
I have an idea, DBX or vl-propagate + s::startup

Brick_top

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #14 on: November 28, 2011, 05:18:27 AM »
will the s::startup function define functions for every drawing?