write to file fails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Found it
For some strange reason only 1 variable was messing around
Fixed it 🙂
Dear forum members,
I have a lsp that reads out ATT of my templates ( used in Plant 3D 2016)
There are 3 parts ( 2 different templates ) in this script and 2 of them working fine
the 3th one keeps failing
This is what I do
(setq blk (ssname (ssget "x" (list (cons 0 "INSERT") (cons 2 "Title Block")))0))
Then I read out specific ATT's
This is for the first 2 parts
(setq revdate (LM:GetAttributeValue blk "Rev_Date" ))
(setq dwgname (getvar "DWGNAME" )) ;incl extension
(setq tempsize (LM:GetAttributeValue blk "TEMPLATESIZE" ))
(setq strrev (LM:GetAttributeValue blk "REV" ))
(setq status_o (LM:GetAttributeValue blk "STATUS_O" ))
(setq status_t (LM:GetAttributeValue blk "STATUS_T" ))
(setq strtitle (LM:GetAttributeValue blk "TITLE" )) ; needed for DRS
;(setq strname (LM:GetAttributeValue blk "linenumber" ))
(setq dwgprefix (getvar "dwgprefix"))
(setq fn (strcat DRSlijst "output.csv")
fp (open fn "a")
)
(write-line (strcat revdate dlm dwgname dlm tempsize dlm strrev dlm status_o dlm status_t dlm strtitle dlm dwgprefix) fp)
(close fp)
This works perfect but now the 3th part
(setq blk (ssname (ssget "x" (list (cons 0 "INSERT") (cons 2 "Title Block")))0))
(setq revdate (LM:GetAttributeValue blk "Rev_Date" ))
(setq dwgname (getvar "DWGNAME" )) ;incl extension
(setq tempsize (LM:GetAttributeValue blk "TEMPLATESIZE" )) is different then above
(setq strrev (LM:GetAttributeValue blk "ISO_REV" ))
(setq status_o (LM:GetAttributeValue blk "STATUS_O" ))
(setq status_t (LM:GetAttributeValue blk "STATUS_T" ))
(setq strtitle (LM:GetAttributeValue blk "ISO_TITLE_2" )) is different then above
;(setq strname (LM:GetAttributeValue blk "linenumber" ))
(setq dwgprefix (getvar "dwgprefix"))
Besides the ATT"s its the same as above
Now when writing to file it gives me Command: ; error: bad argument type: stringp nil And not even on every dwg but only a few
I use this to write to the file
(write-line (strcat revdate dlm dwgname dlm tempsize dlm strrev dlm status_o dlm status_t dlm strtitle dlm dwgprefix) fp)
When Im going to use the following it works perfect
(princ revdate fp)
(princ " " fp)
(princ dwgname fp)
(princ " " fp)
(princ tempsize fp)
(princ " " fp)
(princ strrev fp)
(princ " " fp)
(princ status_o fp)
(princ " " fp)
(princ status_t fp)
(princ " " fp)
(princ strtitle fp)
(princ " " fp)
(princ dwgprefix fp)
(princ " " fp)
;(princ strname fp)
;(princ " " fp)
(princ "\n" fp)
(close fp)
My question is why is the princ working and the write-line not
If you need more info please let me know
Best regards
Kind Regards