AutoCAD Electrical General Discussion

AutoCAD Electrical General Discussion

Reply
Distinguished Contributor
acade2012
Posts: 116
Registered: ‎04-24-2012
Message 1 of 5 (474 Views)
Accepted Solution

sheet number lisp rotine help

474 Views, 4 Replies
12-04-2012 06:56 AM

hello All,

I am tring to develop a lisp routine to change the sheet number to match the last 3 digits of the drawing number.

 

I have been able to get and write the proper number the the sheet value but it adds it to the existing sheet value.

 

Can anyone help me with deleting or overwriting that sheet value before i add the correct value??

 

Thanks

 

Dennis

 

 

(prompt "\nType AAA to run.....")

(defun c:aaa ()   

        (COMMAND "-ATTEDIT" "N" "N" "WD_M" "SHEET" "" "" (SUBSTR (GETVAR "DWGNAME") (- (STRLEN (GETVAR "DWGNAME")) 6) 3))

 (princ) )

 

the result finds the correct number and adds it to the existing sheet number i need it to overwrite the sheet number

Distinguished Contributor
acade2012
Posts: 116
Registered: ‎04-24-2012
Message 2 of 5 (459 Views)

Re: sheet number lisp rotine help

12-04-2012 08:50 AM in reply to: acade2012

I did notice with the 2nd set of empty "". this is looking for a value to search for and replace. If i put in the current sheet value is changes it correctly.

 

the issue is that value changes from drawing to drawing.

 

I tried to get the current sheet value out but I am not having any luck.

 

i have tried the follwing

 

SETQ SHTNUM (GET_ATTR "WD_M" "SHEET" )

 

SETQ SHTNUM (GETVAR SHEET)

 

ANY IDEAS?

Distinguished Contributor
acade2012
Posts: 116
Registered: ‎04-24-2012
Message 3 of 5 (451 Views)

Re: sheet number lisp rotine help

12-04-2012 11:17 AM in reply to: acade2012

HERE IS WHAT I ENDED UP FIGURING OUT

 

FIRST LINE CLEARS THE SHEET NUMBER AND THE SECOND COPIES THE DRAWING NUMBER (ISTATING AT INTIGER 6 GOING 3 PLACES)

 

HOPE THIS WILL HELP SOMEONE!!!

 

 

(prompt "\nType SHTNUM to run.....")

(defun c:smileyfrustrated:HTNUM ()

     (c:wd_modattrval (ssname(ssget "x" (list (cons 0 "insert")(cons 2 "WD_M"))) 0) "SHEET" "" 1)     ;CLEARS SHEET VALUE

        (COMMAND "-ATTEDIT" "N" "N" "WD_M" "SHEET" "" "" (SUBSTR (GETVAR "DWGNAME") (- (STRLEN (GETVAR "DWGNAME")) 6) 3)) ;SET SHEET VALUE=DWGNAME

   (PRINC) )

 

 

Member
erg.cgs
Posts: 4
Registered: ‎04-15-2008
Message 4 of 5 (245 Views)

Re: sheet number lisp rotine help

11-12-2013 10:42 AM in reply to: acade2012

This worked perfect for me. One thing, the "SmileyFrustrated" (:smileyfrustrated:) is really a colon (":") followed by a capital "S".

*Expert Elite*
rhesusminus
Posts: 910
Registered: ‎09-21-2007
Message 5 of 5 (230 Views)

Re: sheet number lisp rotine help

11-13-2013 02:21 AM in reply to: erg.cgs

This "short version" does the same... No need to clear the value and then use the -ATTEDIT to set the new value. Just set it directly.

 

(prompt "\nType SHTNUM to run.....")
(defun c:SHTNUM ()
     (c:wd_modattrval (ssname(ssget "x" (list (cons 0 "insert")(cons 2 "WD_M"))) 0) "SHEET" (SUBSTR (GETVAR "DWGNAME") (- (STRLEN (GETVAR "DWGNAME")) 6) 3) 1)
 (PRINC)
)

 


THL
Please select "Accept As Solution" if this post answers your question. Kudos don't hurt either. ;-)
Announcements
Manufacturing Community
The Manufacturing Community provides additional access to tips, tutorials, blogs and networking with peers.
Need installation help?

Start with some of our most frequented solutions to get help installing your software.

New AutoCAD Electrical Category!

The AutoCAD Electrical forum has moved into it's very own category page, and can no longer be found within the Additional Product Forums.