Author Topic: Setting variables in a file opened by a routine?  (Read 4629 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?

shawndoe

  • Guest
Re: Setting variables in a file opened by a routine?
« Reply #15 on: December 16, 2011, 04:22:33 PM »
Hi,

It's a bit late, but I have a routine that also opens a new drawing from another and I found that (vl-bb-set/ref) is a much better option.  Vl-propogate dumps global variables in the new drawing which may cause problems.  I'm also under the impression that you can't access vl-propogate variables until after the S::STARTUP has finished.

Have a good one.
Shawndoe

GDF

  • Water Moccasin
  • Posts: 2081
Re: Setting variables in a file opened by a routine?
« Reply #16 on: December 16, 2011, 05:12:10 PM »
I use vl-registry-write and vl-registry-read.

Example: setting globals for dialog box controls.
(defun ARCH:SETDIALMODE  (key /)
  (vl-registry-write
    "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\Display"
    ""
    key)
  (setq ARCH#DIAL
         (vl-registry-read
           "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\Display"))
  (princ))
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Setting variables in a file opened by a routine?
« Reply #17 on: December 16, 2011, 06:35:54 PM »
setcfg / getcfg  8-)
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

BlackBox

  • King Gator
  • Posts: 3770
Re: Setting variables in a file opened by a routine?
« Reply #18 on: December 17, 2011, 12:38:22 AM »
Code - Auto/Visual Lisp: [Select]
  8-)

FTFY :wink:

** Note - the LISP functions are now hyperlinked to the help documentation.
« Last Edit: December 17, 2011, 04:12:51 AM by RenderMan »
"How we think determines what we do, and what we do determines what we get."

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Setting variables in a file opened by a routine?
« Reply #19 on: December 17, 2011, 03:43:09 AM »
I quit using setcfg and getcfg some years ago after I realized that it was causing the config file to grow and you have to manually remove orphaned entries.

Use the registry and then you can programmatically delete the keys after you no longer need them.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Setting variables in a file opened by a routine?
« Reply #20 on: December 17, 2011, 09:24:34 AM »
I quit using setcfg and getcfg some years ago after I realized that it was causing the config file to grow and you have to manually remove orphaned entries.

Use the registry and then you can programmatically delete the keys after you no longer need them.
The registry is a great option also.

As long as you keep reusing the same cfg there is no issue with file bloat.  Just another way.  :kewl:
(i.e. "AppData/Vars/var1")

There are also the setenv / getenv variables.

Code - Auto/Visual Lisp: [Select]
*This was for you RenderMan :angel:

All great options as long as the limitations are taken into account.
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

BlackBox

  • King Gator
  • Posts: 3770
Re: Setting variables in a file opened by a routine?
« Reply #21 on: December 17, 2011, 06:07:02 PM »

There are also the setenv / getenv variables.

Code - Auto/Visual Lisp: [Select]
*This was for you RenderMan :angel:

 :-P
"How we think determines what we do, and what we do determines what we get."