Author Topic: Get block list and rename blocks....  (Read 17331 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Get block list and rename blocks....
« Reply #30 on: August 12, 2009, 02:50:49 PM »
Ok, with the equal, eq, and = functions, this is my take on things:

equal, I would use on 2 numerical expressions (where a fuzz factor may be needed).
eq, I would use on 2 strings/numerical expressions (where the expressions must match exactly).
=, I would normally use when I need to compare more than two expressions.

Bear in mind that eq and equal will only take 2 args, whereas = will take an arbitrary number of args.

Lee




Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Get block list and rename blocks....
« Reply #31 on: August 12, 2009, 02:55:51 PM »
Regarding localising of variables,

I don't think the order matters (don't quote me on that), but I normally order them in the order they are defined in the program.

Just look at it like this, if any values are bound to the symbols that are localised, those values will be set to nil upon the program commencing and completing.

As an example:

Code: [Select]
(defun c:test ( )

  (setq a "Hello")

  (printer)

  (princ))


(defun printer ( )

  (princ a)

  (princ))

^^ "a" remains global.

Code: [Select]
(defun c:test (/ a)

  (setq a "Hello")

  (printer)

  (princ))


(defun printer ( )

  (princ a)

  (princ))

^^ "a" is localised in the main function, and hence will still hold its value in the sub-function, but nil after program completion.

Code: [Select]
(defun c:test (/ a)

  (setq a "Hello")

  (printer)

  (princ))


(defun printer (/ a)

  (princ a)

  (princ))

^^ "a" is localised in the sub-function, hence its value is set to nil upon invoking the sub-function, hence the above will print nil.

Hope this helps,

Lee


KewlToyZ

  • Guest
Re: Get block list and rename blocks....
« Reply #32 on: August 12, 2009, 04:34:46 PM »
FYI, I finally realized why I was getting the long symbol names error when I used -ExportToAutoCAD.
I had set the format in the profile to R14 quite awhile ago by mistake.
Apparanetly it retained the format version and r14 had 16 bit file path names. 
I never thought to check it.
:realmad: :pissed: :lmao: :ugly: Yeah my Avatar is spot on.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Get block list and rename blocks....
« Reply #33 on: August 12, 2009, 05:14:54 PM »
Pay attention when comparing things other than strings and numbers!
Code: [Select]
_$ (setq e1 (car(entsel)))
<Entity name: 1b95418>
_$ (setq e2 (car(entsel)))
<Entity name: 1b95418>
_$ (eq e1 e2)
T
_$ (equal e1 e2)
T
_$ (= e1 e2)
nil
_$ (setq el1 (entget e1))
((-1 . <Entity name: 1b95418>) (0 . "MTEXT") (330 . <Entity name: 1b95010>) (5 . "9B") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "zDtl Light 1") (100 . "AcDbMText") (10 33.9178 5.10906 0.0) (40 . 0.0625) (41 . 1.42614) (71 . 1) (72 . 5) (3 . "NOTES:")(7 . "PS1-16") (210 0.0 0.0 1.0) (11 1.0 -2.44921e-016 0.0) (42 . 1.41207) (43 . 1.1875) (50 . 0.0) (73 . 1) (44 . 0.9))
_$ (setq el2 (entget e2))
((-1 . <Entity name: 1b95418>) (0 . "MTEXT") (330 . <Entity name: 1b95010>) (5 . "9B") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "zDtl Light 1") (100 . "AcDbMText") (10 33.9178 5.10906 0.0) (40 . 0.0625) (41 . 1.42614) (71 . 1) (72 . 5) (3 . "NOTES:")(7 . "PS1-16") (210 0.0 0.0 1.0) (11 1.0 -2.44921e-016 0.0) (42 . 1.41207) (43 . 1.1875) (50 . 0.0) (73 . 1) (44 . 0.9))
_$ (eq el1 el2)
nil
_$ (equal el1 el2)
T
_$ (= el1 el2)
nil
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Get block list and rename blocks....
« Reply #34 on: August 12, 2009, 07:13:49 PM »
Ooo, didn't know that Alan, thanks  8-)

KewlToyZ

  • Guest
Re: Get block list and rename blocks....
« Reply #35 on: August 14, 2009, 09:01:11 AM »
That is tricky, makes me want to go back and recode everything out of paranoia now  :lol: ;-)
Actually it would likely do me some good, I need the repetition anyhow.

Is there a post/guide about how to use Atoms Family as sort of a vla programming guide?
More or less help me along with recognizing the progression to drill down into objects and the drawing database?

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Get block list and rename blocks....
« Reply #36 on: August 14, 2009, 10:08:54 AM »
I'm not sure what you mean by using the Atoms-Family as a programming guide.

But on the lines of the Atoms-family, be sure to check out Atoms.vlx by MP on here - a superb reference facility...

Also, the VLIDE help files have a ton of info.  :-)

KewlToyZ

  • Guest
Re: Get block list and rename blocks....
« Reply #37 on: August 14, 2009, 11:40:40 AM »
Thanks Lee, yeah I have MP's vlx.
I keep looking for a means to follow the code like in Visual Studio inteligent highlighting (Intellisense?);
Lets me know what portions are available as an option while I type.
.... yeah I know lazy but it is a nice feature. :lmao:

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Get block list and rename blocks....
« Reply #38 on: August 14, 2009, 01:14:00 PM »
Ahh, I see what you mean - I don't believe VL has Intellisense, but try the Apropos, ctrl+shift+space or, if you are halfway through a code, and the function has already been used, you can use the auto-complete ctrl+space   :-)