Jump to content

Recommended Posts

Posted (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 by juicyorange
tags
Posted
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!

Posted

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

Posted
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.

 

Posted (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 by juicyorange
Posted (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 by juicyorange

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...