Author Topic: getfiled confusion  (Read 2788 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
getfiled confusion
« on: August 26, 2009, 10:53:09 AM »
A question at another forum got me thinking, and realising that I do not completely understand the getfiled function all too well...


In the help files, it says to use an integer between 0 and 15 for the flags to set, however I personally have only ever used the bit values: 1, 4, 8, 16, 32, 64 & 128 for this purpose.

But this raises the question that, if you can use both, how does AutoCAD know whether you want bit code 8, or (3 + 5)?

Another thing: The help file options are very confusing as to which combination of bits mean that the filepath is stripped and which you should set for different purposes.

For example, I normally use bit 8 to prompt for an existing file to use, however, if the file is in the search path, it will strip the filepath - and so I would normally then use findfile to get the filepath back.

But, it mentions that you can set bit 1 (or 0?) to prevent it from searching the library and hence stripping the filepath... but that would mean it is prompting for a new file, which I wouldn't want......ahh the confusion!

I would be grateful to anyone who could point me in the right direction with this..   :ugly:


Many Thanks,

Lee


MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: getfiled confusion
« Reply #1 on: August 26, 2009, 11:19:17 AM »
To fully appreciate bit coded integers it's best to think binary. "Bit code values" fall on 2 raised to the power of n boundaries (1 2 4 8 16 ...), i.e. there is no 3 bit, there is no 5 bit. So "bit code value" 8 stands on its own, being 00001000 in binary -- it is not the "oring" of other bit code values. To use multiple bit code values you perform a bit wise or, for example to use 1 or 8 or 32 you or them together, yielding 41. See the logior function.

If I interpret what you want from your post a flags value of 33 (1 or 32) would achieve what you want. I'll let you read the AutoLISP Reference to find out why. I agree the docs could be written better. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Sebb77

  • Guest
Re: getfiled confusion
« Reply #2 on: August 26, 2009, 11:54:25 AM »
I always use the bit 16, since i want the whole file path. According to what i understand,  this is what you seek.
Try it out, peace!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: getfiled confusion
« Reply #3 on: August 26, 2009, 12:02:04 PM »
I like visual.   8-)
« Last Edit: August 26, 2009, 12:08:46 PM by CAB »
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.

JohnK

  • Administrator
  • Seagull
  • Posts: 10669
Re: getfiled confusion
« Reply #4 on: August 26, 2009, 12:18:48 PM »
I was taught (I think--but it could have been my own attempt to understand too-) with an ice cube tray analogy.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10669
Re: getfiled confusion
« Reply #5 on: August 26, 2009, 12:21:08 PM »
...now that i try to recall that analogy; *DONT* think of an icecube tray cause it kinda dont work very well at all.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: getfiled confusion
« Reply #6 on: August 26, 2009, 12:22:13 PM »
Play with the attached. It's kinda long in the tooth and horrible coding but it may illuminate:

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: getfiled confusion
« Reply #7 on: August 26, 2009, 12:59:29 PM »
Firstly, Thanks for all the great replies guys - tons of superb information and advice.

I always use the bit 16, since i want the whole file path. According to what i understand,  this is what you seek.
Try it out, peace!

I just tried this, and yes, this is a great alternative that I shall use from here on in - many thanks for pointing that out, the write up in the help files doesn't explain it too well whatsoever.

To fully appreciate bit coded integers it's best to think binary. "Bit code values" fall on 2 raised to the power of n boundaries (1 2 4 8 16 ...), i.e. there is no 3 bit, there is no 5 bit. So "bit code value" 8 stands on its own, being 00001000 in binary -- it is not the "oring" of other bit code values. To use multiple bit code values you perform a bit wise or, for example to use 1 or 8 or 32 you or them together, yielding 41. See the logior function.

If I interpret what you want from your post a flags value of 33 (1 or 32) would achieve what you want. I'll let you read the AutoLISP Reference to find out why. I agree the docs could be written better. :)

Michael (and all others who helped explain), thank you for explaining the binary logic for me - I had a rough idea of binary, and how you had to combine it to get both options, but if I'm honest, I could do with studying the logior, logand etc functions in a lot more detail. Currently I use mostly the logand function to check if a bit code is "contained" in a combination of bit codes... if that makes sense...   :|  (for example checking for a group 70 XRef code in a block def).

Thanks also for the LISP and DCL - I shall study these in more detail, (as my DCL knowledge needs a great deal of improvement too...).

Just to get some of my dignity back, I did understand that the 0-15 integers were not bit-codes, and that bit-codes were integers of base 2 - but just that in the ACAD help, they label them as "bit 0", and "bit 5" etc. - and so I wanted to make it clear what I was referring to.   :-)

Thanks guys,

Lee

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: getfiled confusion
« Reply #8 on: August 27, 2009, 04:24:05 PM »
A little routine which returns a list of the bit codes of a bit-coded integer

Code: [Select]
(defun bitCodes (n / b)
  (if (/= 0 n)
    (cons (setq b (expt 2 (fix (/ (log n) (log 2)))))
  (bitCodes (- n b))
    )
  )
)
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: getfiled confusion
« Reply #9 on: August 27, 2009, 05:39:03 PM »
Very clever Gile.

Still trying to get my head around the mathematics behind it... and I'm meant to be doing a maths degree...   :|