custom drawing property expressions

custom drawing property expressions

Anonymous
Not applicable
1,475 Views
6 Replies
Message 1 of 7

custom drawing property expressions

Anonymous
Not applicable

We use a very simple way to organize our revision levels and the history of our drawings.  we have a 5 digit family number and the revision level.

 

so each file is "55555A.dwg", or "55555B.dwg", and then "55555C.dwg".

I want to look up the revision level inside the drawing properties file name (without the ".dwg") inside a custom drawing property.

 

So right now, we can open rev "55555A" and save as to rev "55555B" and then I would love it if the custom property will automatically update the revision level to "B" based on the file name property.

 

I cannot seem to find text string equations that will work inside the drawing properties.  I know exactly how to do this in excel of course  🙂

 

Thank you all.

 

custom property.JPG

john.vellek has embedded your image(s) for clarity

0 Likes
1,476 Views
6 Replies
Replies (6)
Message 2 of 7

john.uhden
Mentor
Mentor

This was supposed to be a decent answer.  But it is not.

I got lazy and resorted to old-time methods.

Test the functions out, followed by the DWGPROPS command, and see what I mean.

(defun @getdwgprops ( / Doc Dicts Props handle ent custom)
  (vl-load-com)
  (setq Doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq Dicts (vlax-get Doc 'Dictionaries))
  (setq props (vla-item Dicts "DwgProps"))
  (setq handle (vlax-get Props 'Handle))
  (setq ent (entget (handent handle)))
  (setq custom (vl-remove-if-not '(lambda (x)(<= 300 (car x) 309)) ent))
)

(defun @setdwgprop (ID Name Value / Doc Dicts Props handle e ent)
  (and
    (setq ok 1)
    (or (vl-load-com) 1)
    (setq ok 2)
    (setq Doc (vla-get-activedocument (vlax-get-acad-object)))
    (setq ok 3)
    (setq Dicts (vlax-get Doc 'Dictionaries))
    (setq ok 4)
    (setq props (vla-item Dicts "DwgProps"))
    (setq ok 5)
    (setq handle (vlax-get Props 'Handle))
    (setq ok 6)
    (setq e (handent handle))
    (setq ent (entget e))
    (setq ok 7)
    (or
      (and (= (type ID) 'INT)(<= 300  ID 309))
      (alert "ID must be an integer in the range from 300 to 309")
    )
    (setq ok 8)
    (or (= (type Name) 'STR)
      (alert "Name must be a string.")
    )
    (setq ok 9)
    (or (= (type Value) 'STR)
      (alert "Value must be a string.")
    )
    (setq ok 10)
    (setq ent (subst (cons ID (strcat Name "=" Value))(assoc ID ent) ent))
    (entmod ent)
    (setq ok 11)
    (entupd e)
    (setq ok 12)
  )
  ent
)

John F. Uhden

0 Likes
Message 3 of 7

Anonymous
Not applicable

I assumed this was meant to be made into a script file but when I run it I receive an error and then it stops.  Where can I put this code to run it?

 

Thank you

0 Likes
Message 4 of 7

john.uhden
Mentor
Mentor
You can copy and paste right into your command line (not the drawing).

At the command prompt, enter (@getdwgprops) to see what custom properties
are currently saved in your drawing. Include the parentheses.

At the command prompt, enter say (@setdwgprop 300 "TEST" "Testing").
Include the parentheses.

After that, type in the DWGPROPS command to see what was added, and where.

I'm sure I had had this working on a previous employer's PC, but I guess I
left it there. This recreation is an embarassment, but I figured that the
smart ones here would come to my rescue.

John F. Uhden

0 Likes
Message 5 of 7

Anonymous
Not applicable

It almost worked the first time, now it literally transforms it all into an image and pastes the image into the drawing.  In model space it seems to either start a new drawing and asks me to choose a template but will also bring up the help menu.   LOL

It really is hilariously random, I assumed the same code would do the same thing everytime.

 

once again, the code is copied from here to word as text only and then from word to my command line.

0 Likes
Message 6 of 7

john.uhden
Mentor
Mentor
Are you sure you weren't trying it out at cocktail time? That's the
strangest response I have ever seen. I wonder if Word had anything to do
with it.

John F. Uhden

0 Likes
Message 7 of 7

john.uhden
Mentor
Mentor

Thanks to some kind people here who had me knighted, I now have C3D 2016 installed and running (barely).  I cannot as yet find the DWGPROPS dictionary.  In fact, even though the DWG dictionary allegedly contains 31 items, this is all I get...

 

Command: (VLAX-FOR ITEM DICTS (PRINT (VLAX-GET ITEM 'NAME)))

"ACAD_BACKGROUND"
"ACAD_CIP_PREVIOUS_PRODUCT_INFO"
"ACAD_COLOR"
"ACAD_DETAILVIEWSTYLE" ; error: ActiveX Server returned the error: unknown name: "NAME"

 

I guess that at least one of them has no Name property, so let's try that again...

 

Command: (VLAX-FOR ITEM DICTS (if (vlax-property-available-p item 'Name)(PRINT (VLAX-GET ITEM 'NAME))))

"ACAD_BACKGROUND"
"ACAD_CIP_PREVIOUS_PRODUCT_INFO"
"ACAD_COLOR"
"ACAD_DETAILVIEWSTYLE"
"ACAD_MLEADERSTYLE"
"ACAD_MLINESTYLE"
"ACAD_PLOTSTYLENAME"
"ACAD_SCALELIST"
"ACAD_SECTIONVIEWSTYLE"
"ACAD_TABLESTYLE"
"ACAD_VISUALSTYLE"
"AcDbVariableDictionary"
"ADE_QUERY_LIBRARY"
"AEC_CLASSIFICATION_SYSTEM_DEFS"
"AEC_DISP_REP_CONFIGURATIONS"
"AEC_DISP_REP_SETS"
"AEC_DISP_REPS"
"AEC_DISPLAY_PROPS_DEFAULTS"
"AEC_MVBLOCK_DEFS"
"AEC_PROPERTY_SET_DEFS"
"AEC_VARS"
"AECC_NETWORK_PART_DEFS"
"ASE_INDEX_DICTIONARY"
"Autodesk_MAP"
"{24DE2741-47F6-4298-B91B-737E814BAE3E}"

 

Hmm, still no DWGPROPS.

 

John F. Uhden

0 Likes