Author Topic: Check for avalible linetypes?  (Read 3544 times)

0 Members and 1 Guest are viewing this topic.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Check for avalible linetypes?
« on: July 06, 2006, 01:10:02 PM »
Hey guys/ gals,

just dropped by for a quick second.  'been racking my brain triing ro find a way to check for a linetype.  In other words, if I try to load a linetype that doesn't exsist I get an error.  How can I trap that error?

Thanks all
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Check for avalible linetypes?
« Reply #1 on: July 06, 2006, 01:18:01 PM »
Not exactly what you want but perhaps this post will help.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Check for avalible linetypes?
« Reply #2 on: July 06, 2006, 01:19:29 PM »
This should work for you.

Code: [Select]
(vl-catch-all-apply 'vla-Load
 (list
  (vla-get-Linetypes
   (vla-get-ActiveDocument
    (vlax-get-Acad-Object)
   )
  )
  "Testing"
 )
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Check for avalible linetypes?
« Reply #3 on: July 06, 2006, 02:50:18 PM »
Thanks for the quick response.  I couldn't seem te get the exact result fom  you examples but I pushed on and came up with this dirty bird:
Code: [Select]
(defun CHECK_LINETYPE (LINFile Linetype / OpenFile LineNumber CurrentLine Result)
(setq OpenFile (open LINFile "r"))
(while (setq CurrentLine (read-line OpenFile))
(if (wcmatch CurrentLine "`**")
(progn
(setq LinetypeName (substr(car(TGS:Stringtolist CurrentLine ","))2))
(if (= (strcase Linetype) LinetypeName)
(setq Result T)
)
)
)
)
(close OpenFile)
Result
)
Not the prettiest but it seems to work.

There is a string to list sub that isn't included so if anyone wants to test and needs the sub just let me know.

Thanks again,

That is why I love this place.
« Last Edit: July 06, 2006, 02:58:12 PM by CAB »
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Check for avalible linetypes?
« Reply #4 on: July 06, 2006, 03:36:55 PM »
Tim..

What happen when your linetype isn't in the LIN file...but it is in your dwg file ?
What happen if isn't in your current LIN file...but it is in anothe LIN file ?

 :?

maybe you should combine your routine with
Code: [Select]
(ai_table "LTYPE" 0)
or maybe put all your LIN file location in list and than check for each LIN file in this list..

suggestion.. :wink:
« Last Edit: July 06, 2006, 03:40:19 PM by Andrea »
Keep smile...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Check for avalible linetypes?
« Reply #5 on: July 06, 2006, 03:50:52 PM »
Tim..

What happen when your linetype isn't in the LIN file...but it is in your dwg file ?
What happen if isn't in your current LIN file...but it is in anothe LIN file ?

 :?

maybe you should combine your routine with
Code: [Select]
(ai_table "LTYPE" 0)
or maybe put all your LIN file location in list and than check for each LIN file in this list..

suggestion.. :wink:
Good points.  I don't use too many special linetypes, only ones supplied by Acad, or my Helpdesk people, so I don't really have to worry about this.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Check for avalible linetypes?
« Reply #6 on: July 06, 2006, 04:02:49 PM »
Good points indeed.

I first check the drawing to see if the supplied LT is in there.  If it isn't I then check the acad.lin file.  All of the variable are supplied by a macro with the exception of the .lin file.  Like Tim said we only use what is supplied by autodesk.  If we find a need for a special one we just add it to the .lin file.

This is part of a Quick hatching menu that we use here.

To give a little background:

I started this job about 3-4 mo. ago.  They use ADT'06. They have a custom pulldown with quick hatching in it, like foundations, walls, etc.  Well they change the system variable and change layers but never reset anything (they were doing it with macros)  So I decided to take it upon my self to "fix" some of the issues, so i created a hatching program (I will post it tom. for all to see).This is part of the checking.

Thanks again for the suggestions.  Keep them coming, it will only make it more robust.

Tim
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Check for avalible linetypes?
« Reply #7 on: July 06, 2006, 04:35:18 PM »
My version:  :-)
Code: [Select]
;;  CAB 07/06/2006
(defun checkfile_linetype (linfile linetype / openfile currentline result)
  (setq linetype (strcat "*" (strcase linetype)))
  (and
    (setq linfile (findfile linfile))
    (setq openfile (open linfile "r"))
    (while
      (and (setq currentline (read-line openfile))
           (not ; any failure, stay in loop
             (and
               (zerop (vl-string-search linetype (strcase currentline)))
               (setq result t)
             )
           )
      )
    )
  )
  (and openfile (close openfile))
  result
)
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Check for avalible linetypes?
« Reply #8 on: July 06, 2006, 04:43:59 PM »
Returns the first file where the Linetype is found.

Code: [Select]
(defun c:test()
  (setq lt "footsteps"
        files '("acad.lin" "CAB.lin" "acasiso.lin"))
  (vl-some '(lambda(x) (if (checkfile_linetype x lt) x)) files)
)

Command: test
"CAB.lin"
« Last Edit: July 07, 2006, 11:08:33 AM 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.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Check for avalible linetypes?
« Reply #9 on: July 07, 2006, 07:43:23 AM »
CAB,

as usual you da' man that is nice (I just checked it out his morning).

<going away to see if I can brak it :o)~ >
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

GDF

  • Water Moccasin
  • Posts: 2081
Re: Check for avalible linetypes?
« Reply #10 on: July 07, 2006, 09:27:15 AM »
Returns the first file where the Linetype is found.

Code: [Select]
(defun c:test()
  (setq lt "footsteps"
        files '("acad.lin" "CAB.lin" "acasiso.lin"))
  (vl-some '(lambda(x) (if (check_linetype x lt) x)) files)
)

Command: test
"CAB.lin"


Alan

Just a quick look..
(vl-some '(lambda(x) (if (checkfile_linetype x lt) x)) files)

still get
; error: bad argument type: numberp: nil

Gary



Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Check for avalible linetypes?
« Reply #11 on: July 07, 2006, 11:09:39 AM »
Thanks Gary, fixed the code.
I changed the name after I tested it. :-(
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.