Jump to content

Recommended Posts

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    15

  • Newby Bern

    13

  • stevesfr

    4

  • MSasu

    2

Top Posters In This Topic

Posted Images

Posted
Can this not be achieved by simply using Express Tools?

 

Express Tools > Blocks > Export Attribute Information > Specify Output File Name > Select Blocks

 

Open the resultant text file in Excel, edit your attributes and hit save.

 

Back to AutoCAD..

 

Express Tools > Blocks > Import Attribute Information > Select Saved Text File

 

Hi, I am trying to make this as 'idiot proof' as possible. I don't want the cad user to undertake any 'complicated' actions and if the blocks upated 'behind the scenes' on loading even better. At least, now, they only need to load the relevent CSV file and all else happens simply. The database is required to place the same information into other word/excel documents, so this shall ensure the minimising of 'error traps'.

Posted
Tharwat, still having problems.......... attached are my files. appreciate your help in what I am doing wrong.

Steve

 

The Handle value is Case-sensitive so Capital and Small letters are not considered equally ;)

 

So take a close look at the Attributed Block handle value and the one in your excel file then do not forget to change the semi-colon to comma

as I have indicated to in this POST

 

Let me know :)

Posted

Tharwat, I would be interested to know if you got my csv file to revise the block attributes in the dwg file I sent previous.

I changed the semi-colon to a comma, but no luck yet.

Steve

Posted

Did you modify the excel file to obtain the correct handle value ? the char c must be in capital the same as the Handle value

of the attributed block .

Posted
Did you modify the excel file to obtain the correct handle value ? the char c must be in capital the same as the Handle value

of the attributed block .

 

Friend Tharwat, changing the c to C did the trick. When listing the block in Acad, the block handle was 19c, but changing the csv file to upper case C, did the trick.

Thank You for all the patience and help. !!!! why the difference from Acad I don't know, but it now is OK.

Steve

Posted
Friend Tharwat, changing the c to C did the trick. When listing the block in Acad, the block handle was 19c

 

I don't know how you did extract the handle of the objects , so I can say nothing in this regard .

 

Thank You for all the patience and help. !!!! why the difference from Acad I don't know, but it now is OK.

Steve

 

You're welcome anytime :)

Posted

Tharwat, good afternoon - As a quick 'tweak', could you please advise how to change the routine so that I can define the line

 

(getfiled "Select Excel file to Update Attributes ..."

(getvar 'DWGPREFIX)

"csv"

16

)

 

to link to a specifed CSV file i.e. C:\Users\[folder]\[folder]\PA Speaker.csv then the drawing is opened and updated without any user input (would the 'OpenIt' command come in to play?) - Once again many thanks.

Posted
Tharwat, good afternoon - As a quick 'tweak', could you please advise how to change the routine so that I can define the line

 

(getfiled "Select Excel file to Update Attributes ..."

(getvar 'DWGPREFIX)

"csv"

16

)

 

to link to a specifed CSV file i.e. C:\Users\[folder]\[folder]\PA Speaker.csv then the drawing is opened and updated without any user input (would the 'OpenIt' command come in to play?) - Once again many thanks.

 

Good afternoon to you too :)

 

That is simple , just remove the highlight code in the following line and replace it with the path of the Excel file .

 

(setq f [color=blue][u](getfiled "Select Excel file to Update Attributes ..." (getvar 'DWGPREFIX) "csv" 16)[/u][/color])

Then it should look like this .

 

NOTE : If you decide to have back slashes , you should add two after each other otherwise one forward slash would be enough .

 

And the correct Folder name must be correct as well ;)

e.g :

 

This :
(setq f "C:\\Users\\[color=red][folder][/color]\\[color=red][folder][/color]\\PA Speaker.csv")

or this .

(setq f "C:/Users/[color=red][folder][/color]/[color=red][folder][/color]/PA Speaker.csv")

Good luck .

Posted

I am getting this; "error: extra right paren on input". Do I have one ')' too many?!

Posted
I am getting this; "error: extra right paren on input". Do I have one ')' too many?!

I guess yes , post the modification that you did here to check it out for you .

Posted

Yes, one too many (how do you count them all?!). Works fine now. Once again, many thanks. :D

Posted
Yes, one too many (how do you count them all?!). Works fine now. Once again, many thanks. :D

 

Got used to . :D

  • 2 weeks later...
Posted

I attach the final lisp routine, with some additional minor modifications, for completeness. If added to the lisp startup suite the CSV file referred to within the routine updates all applicable blocks immediately.

 

Hope it helps someone else too, in time. Thanks Tharwat!

CSVload.lsp

Posted

Here a freebie check brackets finds missing brackets. Written about 20 yrs ago, just look at the numbers if you get 0 then code is balanced.

 

(defun c:chkbrk (/ opf bkt chekdfile rdctl wkfile currentln wln ltr ncln)
(setvar "cmdecho" 0)
(prompt "\nlook at end of line")
;(setq chekdfile (getstring "enter name of file :"))
(SETQ chekdfile (getfiled "Enter file name:" " " "LSP" 4))

(setq opf (open chekdfile "r"))
(setq bkt 0)
(setq blkl 0)
(setq rdctl 1)
(setq wkfile (open "c:\temp\wow.lsp" "w"))

(setq currentln "a")
(while (/= blkl 6)
(setq currentln (read-line opf))
(if (= currentln nil)(setq currentln ""))
(if (= currentln "")(setq blkl (+ 1 blkl))(setq blkl 1))
(setq wln currentln)                                                        
(while (/= wln "")
       (setq ltr (substr wln 1 1))
       (setq wln (substr wln 2))
       (cond ((= (ascii ltr) 34) (if (= rdctl 0)(setq rdctl 1)(setq rdctl 0)))
               ((and (= ltr "(")(= rdctl 1))(setq bkt (+ bkt 1)))
               ((and (= ltr ")")(= rdctl 1))(setq bkt (- bkt 1)))
               ((and (= ltr ";")(= rdctl 1))(setq wln ""))
               ;(t (prompt ltr))
       )
)
(setq ncln (strcat currentln ";" (itoa bkt)
(princ (itoa bkt))
(if (= rdctl 0) "string open" "")))
(if (/= currentln "")(write-line ncln wkfile))
)
(close wkfile)
(close opf)
(prompt (strcat "open brakets= " (itoa bkt) "."))
)

(setq ang1 nil
     pt1 nil
     pt2 nil
     pt3 nil
     pt4 nil
     pt5 nil)

(princ)

Posted

Bigal

 

Thanks, but it does work for me, and I did check it using Utility Mill - bracket matcher.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...