Author Topic: How to Assign Value in Custom Tab in Dwgprops  (Read 1417 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 465
How to Assign Value in Custom Tab in Dwgprops
« on: November 02, 2023, 05:13:43 AM »
Can anyone please help?

Here is an example.
Supposed there are tens custom property names in the "Custom" tab in "DWGPROPS" dialogue.
If WeekDay_02 is found in the "Name" column, then Monday is to be added to it's value cell.

Thanks in advance.

Lee Mac

  • Seagull
  • Posts: 12940
  • London, England
Re: How to Assign Value in Custom Tab in Dwgprops
« Reply #1 on: November 02, 2023, 05:40:25 AM »
The key is the ActiveX SummaryInfo object, specifically the SetCustomByKey method.

dexus

  • Bull Frog
  • Posts: 232
Re: How to Assign Value in Custom Tab in Dwgprops
« Reply #2 on: November 02, 2023, 06:01:14 AM »
You can use the code here and call it with: (getCustomDwgProp "name")

MeasureUp

  • Bull Frog
  • Posts: 465
Re: How to Assign Value in Custom Tab in Dwgprops
« Reply #3 on: November 03, 2023, 05:18:35 AM »
Thanks Lee. your reply is always informative. I will ask again if having more questions.
And thanks to dexus. Your code is a helpful example and I will learn from it.

Both helps are much appreciated.

MeasureUp

  • Bull Frog
  • Posts: 465
Re: How to Assign Value in Custom Tab in Dwgprops
« Reply #4 on: November 03, 2023, 06:05:45 AM »
Hi dexus,
How do I apply "if" statement with (getCustomDwgProp "name") function?
I need to search if the name of WeekDay_02 is found then add Monday to the value.
Thanks.

Lee Mac

  • Seagull
  • Posts: 12940
  • London, England
Re: How to Assign Value in Custom Tab in Dwgprops
« Reply #5 on: November 03, 2023, 09:52:47 AM »
Here's a very basic example -
Code - Auto/Visual Lisp: [Select]
  1. (defun foo ( doc key str / sum )
  2.     (setq sum (vla-get-summaryinfo doc))
  3.     (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getcustombykey (list sum key 'out))))
  4.         (progn (vla-setcustombykey sum key str) t)
  5.     )
  6. )
Code - Auto/Visual Lisp: [Select]
  1. (foo (vla-get-activedocument (vlax-get-acad-object)) "WeekDay_02" "Monday")

MeasureUp

  • Bull Frog
  • Posts: 465
Re: How to Assign Value in Custom Tab in Dwgprops
« Reply #6 on: November 04, 2023, 01:06:46 AM »
Thanks again, Lee.

« Last Edit: November 04, 2023, 01:13:31 AM by MeasureUp »