Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: alternate key in lisp expression

  1. #1
    Member
    Join Date
    2004-09
    Posts
    5
    Login to Give a bone
    0

    Default alternate key in lisp expression

    I am trying to write a lisp routine that will open the dwgprops box
    and fill in new information automaticly. No having used lisp for a while
    I need to know how to program the alt key to pick the add file in the box.

    Any help would be appreciated.

  2. #2
    Member
    Join Date
    2003-10
    Posts
    43
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    Are you trying to add information under the Custom tab? If so I have a lisp that will do this, and if your running 2006 I have a cool c# version

    Dan

  3. #3
    Member
    Join Date
    2004-09
    Posts
    5
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    Dan
    that is exactly what I am looking for. I would appreciate it if I could get that inforfmation.
    Ralph

  4. #4
    Member
    Join Date
    2003-10
    Posts
    43
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    Ralph

    Here is a little routine that imports / exports custom properties to and from a .CSV files
    the comands are impdwp , expdwp and clrdwp. The last one will clear the custom properties.
    inside the code you can see the properties and methods.

    Tested with 2005 and 2006

    enjoy
    Attached Files Attached Files

  5. #5
    Member
    Join Date
    2004-09
    Posts
    5
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    thank you very much

  6. #6
    100 Club
    Join Date
    2005-05
    Location
    IL
    Posts
    103
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    FYI...it works with 2004 too. Thanks.

  7. #7
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    Quote Originally Posted by dmarcotte4
    Ralph

    Here is a little routine that imports / exports custom properties to and from a .CSV files
    the comands are impdwp , expdwp and clrdwp. The last one will clear the custom properties.
    inside the code you can see the properties and methods.

    Tested with 2005 and 2006

    enjoy
    Just to let you know, .CSV files have problems if your properties contain commas, (ex. January, 2006)
    to fix this problem possibly use .XLS files instead and change all , additions to t, it works just as well and you can then use commas in your properties. I could post the adjusted file if you dont mind, or I could just keep it to myself

  8. #8
    Member
    Join Date
    2003-10
    Posts
    43
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    yes, that sure is a problem with delimited files… you can’t use the delimiter character .
    I would love to see what you have done with the code.

    thanks
    Daniel

  9. #9
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    Quote Originally Posted by dmarcotte4
    yes, that sure is a problem with delimited files… you can’t use the delimiter character .
    I would love to see what you have done with the code.

    thanks
    Daniel
    Here it is, I highlighted everything I modified in red, the goal was to save the file to a tab delimited file instead of a comma delimited file, and also to always default open to the folder that the current drawing is from (I have not fully tested this ability to see if it always works, although it appears that way.) The changes were relatively simple, in notepad I just found and replaced all CSV references with XLS and then found where it added commas and took them out and replace those with t for tabs.

    If you need to edit the XLS file externally, use notepad, if you use Excel, it will add extra quoatation marks around some of the items.

    the code didn't come in right, so I attached it, please do NOT use the below code

    Code:
     
    (defun c:expdwp ()
    (GetallCustomDwgProp)
    )
    (defun c:impdwp ()
    (ImportallCustomDwgProp)
    )
    (defun c:clrdwp ()
    (ClearCustomDwgProp)
    )
    (defun ClearCustomDwgProp (/ app cnt cnt1 cnt2 doc dwgprops result)
    (vl-load-com)
    (setq
    	result (dwpMsgbox
    	 "Warning"
    	 "Your are about to erase data do you with to contunue?"
    	 vlax-vbOKCancel
    	 vlax-vbExclamation
    	)
    )
    (if (= result 1)
    	(progn
    	 (setq App	 (vlax-Get-Acad-Object)
    	 Doc	 (vla-Get-ActiveDocument App)
    	 DwgProps (vla-Get-SummaryInfo Doc)
    	 cnt1	 0
    	 cnt2	 (vla-NumCustomInfo DwgProps)
    	 )
    	 (repeat cnt2
    (vla-RemoveCustomByIndex DwgProps cnt1)
    	 )
    	 (dwpMsgbox "Done"
    (strcat "Removed "
    	(itoa cnt2)
    	" Items from Custom Properties"
    )
    vlax-vbOKOnly
    vlax-vbInformation
    	 )
    	)
    	(dwpMsgbox "Cancel"
    		"Operation Canceled"
    		vlax-vbOKOnly
    		vlax-vbInformation
    	)
    )
    (princ)
    )
    (defun GetallCustomDwgProp
    	 (/ app counter counter2 doc dwgprops FN dname fh s1 s2)
    (vl-load-com)
    (setq dname (GETVAR "DWGPREFIX"))
    (setq FN (getfiled "Select a File" dname "XLS" 1))
    (if FN
    	(progn
    	 (setq FH (open FN "w"))
    	 (setq App	 (vlax-Get-Acad-Object)
    	 Doc	 (vla-Get-ActiveDocument App)
    	 DwgProps (vla-Get-SummaryInfo Doc)
    	 counter 0
    	 counter2 (vla-NumCustomInfo DwgProps)
    	 )
    	 (repeat counter2
    (vla-GetCustomByIndex DwgProps counter 's1 's2)
    (setq counter (+ 1 counter))
    (princ (strcat s1 "t" s2 "n") FH)
    	 )
    	 (close FH)
    	 (dwpMsgbox "Done"
    (strcat "Exported "
    	(itoa counter2)
    	" Items to "
    	(vl-filename-base FN)
    	(vl-filename-extension FN)
    )
    vlax-vbOKOnly
    vlax-vbInformation
    	 )
    	)
    )
    (princ)
    )
    (defun getCustomDwgProp (key / app doc dwgprops try val)
    (vl-load-com)
    (setq App (vlax-Get-Acad-Object)
    Doc (vla-Get-ActiveDocument App)
    DwgProps (vla-Get-SummaryInfo Doc)
    )
    (cond
    	((vl-catch-all-error-p
    	 (setq try (vl-catch-all-apply
    	 'vla-GetCustomByKey
    	 (list DwgProps key 'val)
    )
    	 )
    	 )
    	 (setq val nil)
    	)
    )
    val
    )
    (defun SetCustomDwgProp (key value / App Doc DwgProps)
    (vl-load-com)
    (setq App (vlax-Get-Acad-Object)
    Doc (vla-Get-ActiveDocument App)
    DwgProps (vla-Get-SummaryInfo Doc)
    )
    (if (getCustomDwgProp key)
    	(vla-SetCustomByKey DwgProps key value)
    	(vla-AddCustomInfo DwgProps key value)
    )
    )
    (defun ImportallCustomDwgProp (/ a b fh fn l dname txtline)
    (setq dname (GETVAR "DWGPREFIX"))
    (setq FN (getfiled "Select a XLS File" dname "XLS" 0))
    (if FN
    	(progn
    	 (setq FH (open FN "r"))
    	 (while (setq txtLine (read-line FH))
    (setq l (strparse (strcat txtLine "") "t")
    	 a (car l)
    	 b (cadr l)
    )
    (if (= b nil)
    (setq b " ")
    )
    (SetCustomDwgProp a b)
    	 )
    	 (close fh)
    	 (dwpMsgbox "Done"
    (strcat "Imported Items from "
    	(vl-filename-base FN)
    	(vl-filename-extension FN)
    )
    vlax-vbOKOnly
    vlax-vbInformation
    	 )
    	)
    )
    (princ)
    )
    (defun strparse (strng chs / len c l s chsl cnt)
    (setq chsl (strtol chs))
    (setq len (strlen strng)
    s ""
    cnt (1+ len)
    )
    (while (> (setq cnt (1- cnt))
    	 0
    )
    	(setq c (substr strng cnt 1))
    	(if (member c chsl)
    	 (if (/= cnt len)
    (setq l (cons s l)
    	 s ""
    )
    	 )
    	 (setq s (strcat c s))
    	)
    )
    (cons s l)
    )
    (defun strtol (s / lst c)
    (repeat (setq c (strlen s))
    	(Setq lst (cons (substr s c 1) lst)
    c (1- c)
    	)
    )
    lst
    )
    (defun dwpMsgBox (Title	 Message MsgBoxType Icon
    	/	 acadobject iicon	 imsgboxtype
    	oldvar	 result strmessage strtitle
    )
    (vl-load-com)
    (setq oldvar (getvar "USERI1"))
    (setvar "USERI1" 0)
    (setq acadobject
    (vlax-get-Acad-Object)
    strTitle title
    strMessage
    Message
    iIcon Icon
    iMsgBoxType
    MsgBoxType
    )
    (vla-eval acadobject
    	 (strcat "ThisDrawing.SetVariable "USERI1", "
    	 "MsgBox (""
    	 strMessage
    	 "","
    	 (itoa (+ iIcon iMsgBoxType))
    	 ",""
    	 strTitle
    	 "")"
    	 )
    )
    (setq result (GETVAR "USERI1"))
    (SETVAR "USERI1" oldvar)
    result
    )
    Attached Files Attached Files
    Last edited by ccowgill; 2006-02-02 at 11:39 AM. Reason: code did not come in correctly

  10. #10
    AUGI Addict sinc's Avatar
    Join Date
    2004-02
    Location
    Colorado
    Posts
    1,986
    Login to Give a bone
    0

    Default Re: alternate key in lisp expression

    Quote Originally Posted by dmarcotte4
    yes, that sure is a problem with delimited files… you can’t use the delimiter character .
    I would love to see what you have done with the code.
    Actually, you can... but it requires another special character.

    Most programs that use .csv files will also parse double-quotes as special characters. Items can be included in double-quotes. If you want to use an actual double-quote character, you should use two successive double-quotes, and place the overall field in double-quotes. An example, containing four items:
    Code:
    "January 1, 2006", "A ""quoted"" word",a third item,"""four"""
    That line in a CSV file equates to the following four items:
    Code:
    January 1, 2006
    A "quoted" word
    a third item
    "four"
    The problem is that not every program parses .csv files the way it should. Yet another argument for a software standards body.
    Last edited by sinc; 2006-02-07 at 11:57 PM. Reason: Clarify example

Page 1 of 2 12 LastLast

Similar Threads

  1. Alternate Decimal Separator for Alternate Units in Dimensions
    By Wish List System in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-08-28, 04:33 PM
  2. some help with a macro expression
    By Doodlemusmaximus in forum AutoCAD Customization
    Replies: 4
    Last Post: 2011-03-21, 10:49 AM
  3. Expression of disapproval
    By garethace in forum DWG TrueView - General
    Replies: 0
    Last Post: 2010-06-01, 12:54 PM
  4. Help with expression
    By fclao in forum AutoLISP
    Replies: 3
    Last Post: 2010-02-24, 10:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •