juicyorange Posted November 21, 2019 Posted November 21, 2019 (edited) Hey guys, I'm looking to assign a custom property to a variable and I have no idea how to do it. In the 0 custom prop I put a testvalue Here is the code I have so far: (vl-load-com) (defun c:test (/) (setq acadObject (vlax-get-Acad-Object) acadDocument (vla-get-Activedocument acadObject) ;; set existing custom properties to dProps dProps (vlax-get-property acadDocument 'Summaryinfo) ) ;; get the value at the specifed index in the dProps and assign it to location (vla-GetCustomByIndex dProps 0 "IMPCSVLOC" location) ) I can't find any documentation on the "vla-GetCustomByIndex" so I don't really know how to use tbh. I've attached a file that has the custom property setup. All insight and help is appreciated. Thanks, JT testfile.dwg Edited November 21, 2019 by juicyorange tags Quote
tombu Posted November 21, 2019 Posted November 21, 2019 Try: (setq si (vla-Get-SummaryInfo (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))) (vla-GetCustomByKey si "IMPCSVLOC" 'pval) (princ pval) (princ) See: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/update-custom-drawing-properties/m-p/3641908#M306757 also shows how to set to a new value or add a new custom info. Quote
juicyorange Posted November 21, 2019 Author Posted November 21, 2019 5 minutes ago, tombu said: Try: (setq si (vla-Get-SummaryInfo (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))) (vla-GetCustomByKey si "IMPCSVLOC" 'pval) (princ pval) (princ) See: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/update-custom-drawing-properties/m-p/3641908#M306757 also shows how to set to a new value or add a new custom info. there we go, exactly what I was looking for. thanks! Quote
juicyorange Posted November 21, 2019 Author Posted November 21, 2019 I seem to have hit another snag. What I'm trying to do is define a default location for a getfile command I have and when I use that string it doesn't use the default location I've set. Here's the code: (vl-load-com) (defun c:test (/) (setq acadObject (vlax-get-Acad-Object) acadDocument (vla-get-Activedocument acadObject) ;; set existing custom properties to dProps dProps (vlax-get-property acadDocument 'Summaryinfo) ) (vla-GetCustomByKey dProps "IMPCSVLOC" 'pval) (setq fileloc (princ pval)) (setq csvfile (getfiled "Select CSV File" fileloc "csv" 10 ) ) ) I have also attached the updated test file. testfile.dwg Quote
tombu Posted November 21, 2019 Posted November 21, 2019 2 hours ago, juicyorange said: I seem to have hit another snag. What I'm trying to do is define a default location for a getfile command I have and when I use that string it doesn't use the default location I've set. Here's the code: (vl-load-com) (defun c:test (/) (setq acadObject (vlax-get-Acad-Object) acadDocument (vla-get-Activedocument acadObject) ;; set existing custom properties to dProps dProps (vlax-get-property acadDocument 'Summaryinfo) ) (vla-GetCustomByKey dProps "IMPCSVLOC" 'pval) (setq csvfile (getfiled "Select CSV File" pval "csv" 10 ) ) ) Simply changing "C:\Users" to "C:\Users\ got it to work, but I removed the fileloc stuff as it didn't seem to serve a purpose. Quote
juicyorange Posted November 21, 2019 Author Posted November 21, 2019 (edited) 1 hour ago, tombu said: Simply changing "C:\Users" to "C:\Users\ got it to work, but I removed the fileloc stuff as it didn't seem to serve a purpose. EDIT I read your code, i'll give it a shot Edited November 21, 2019 by juicyorange Quote
juicyorange Posted November 22, 2019 Author Posted November 22, 2019 (edited) 18 hours ago, tombu said: Simply changing "C:\Users" to "C:\Users\ got it to work, but I removed the fileloc stuff as it didn't seem to serve a purpose. I don't know what I was doing before, but it is working for me now. Thanks! Edited November 22, 2019 by juicyorange Quote
Recommended Posts
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.