Jump to content

Recommended Posts

Posted

Hi there!
I've a problem managing custom keys. I'm not able to check if they exist. If I query a custom key that doens't exist i got an error and it exit the lisp.

What's the right command to accomplish that?

 

(setq App (vlax-Get-Acad-Object)
Doc (vla-Get-ActiveDocument App)
summaryInfo (vla-Get-SummaryInfo Doc)

(IF (/ nil (vla-GetCustomByKey summaryInfo "n_project" 'Value))
  ...
  ...
)

76879880_2019-09-1711_24_32-9655_Sottotetto.dwgProperties.png.69b1ec01b1c1aab79d5cd5c92b9956b2.png

Currently I'm just looking for the number of elements and if they are less then 3 i create them all.. It's time to fix that :)

(IF (< (vla-NumCustomInfo summaryInfo) 3)
    (crea_customkeys summaryInfo)
    )

Thanks for the help!

Dennis

Posted

Hi,

The forward slash ( / ) is a dividing symbol and despite of that, you don't need to check if a variable is not equal to nil to know that it has a value so just remove the (/= ....  nil)  

Posted (edited)

Thanks for the advice! It was a misspelling of "/="  😅

 

anyway i get NIL and not his value

Command: (vla-GetCustomByKey summaryInfo "n_project" 'Value)
nil

It should return "IT.19.9655". Am I missing something?


Thanks!

Edited by MastroLube
Posted

Yeah me also get nil value although that it has a value as per your posted example. ! 

That's really odd. 😕

Posted
1 hour ago, MastroLube said:

Hi there!
I've a problem managing custom keys. I'm not able to check if they exist. If I query a custom key that doens't exist i got an error and it exit the lisp.

What's the right command to accomplish that?

Thanks for the help!

Dennis

(SetCustomDwgProp "Pages" "1")

Will add only if necessary then set the Custom Property "n_project" to "IT.19.9655" using the following code.

(defun getCustomDwgProp	(key / app doc dwgprops try val)
  (vl-load-com)
  (setq	App	 (vlax-Get-Acad-Object)
	Doc	 (vla-Get-ActiveDocument App)
	DwgProps (vla-Get-SummaryInfo Doc)
  )
  (cond
    ((vl-catch-all-error-p
       (setq try (vl-catch-all-apply
		   'vla-GetCustomByKey
		   (list DwgProps key 'val)
		 )
       )
     )
     (setq val nil)
    )
  )
  val
)
(defun SetCustomDwgProp	(key value / App Doc DwgProps)
  (vl-load-com)
  (setq	App	 (vlax-Get-Acad-Object)
	Doc	 (vla-Get-ActiveDocument App)
	DwgProps (vla-Get-SummaryInfo Doc)
  )
  (if (getCustomDwgProp key)
    (vla-SetCustomByKey DwgProps key value)
    (vla-AddCustomInfo DwgProps key value)
  )
)

 

  • Thanks 3

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