Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Writing custom Drawing Properties without ActiveX

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
1362 Views, 6 Replies

Writing custom Drawing Properties without ActiveX

Hello there,

 

I'm trying to write Custom Drawing Properties (DWGPROPS) via "accoreconsole.exe".

 

Lot's of posts here suggest using "vla-SetCustomByKey" but ActiveX is not available for the Core Console.

 

Are there any other workarounds for writing the properties without using ActiveX in AutoLisp?

 

Thanks

6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Yes, you can use C# API, just like this old post read-write-custom-drawing-properties-without-opening-them-in-autocad

You can find the main code just below (which works with AcCoreConsole).

Document activeDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
Database db = activeDoc.Database;
DatabaseSummaryInfoBuilder builder = new DatabaseSummaryInfoBuilder();
builder.Author = "GoCAD";
builder.CustomPropertyTable.Add("Machine Type" , "Milling");
builder.CustomPropertyTable.Add("Model" , "Vertical");
builder.CustomPropertyTable.Add("Year" , "2014");
db.SummaryInfo = builder.ToDatabaseSummaryInfo();

If you have BlockAttributes using custom properties, you need to run the command "UpdateField" as well, but that doesn't work with AcCoreConsole.

Message 3 of 7
olivier.doucet
in reply to: Anonymous

Is there a plain autolisp/cmd alternative approach to both ActiveX and NETLOADing an assembly that would work with accoreconsole.exe?
The solution I am trying to put together should support several versions of autocad and that means potentially having to handle different versions of a C#  plugin. Besides, I am not sure a plugin approach is compliant with our internal security policies.
These are the reasons why I would rather take a more verbose approach but also more versatile. The script would be generated on-the-fly by another process, that will in turn invoke accoreconsole.exe.
I am new to autocad scripting and not sure if what I am asking for is achievable.
But I hope someone here can point me in the right direction.

Message 4 of 7
hak_vz
in reply to: Anonymous

Check this links:

 

https://www.afralisp.net/autolisp/tutorials/dictionaries-and-xrecords.php 

http://vnestr.tripod.com/SaveData.lsp 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 5 of 7
hak_vz
in reply to: olivier.doucet

@olivier.doucetOpen new post in this forum with your request explained in more details i.e what you want to achieve, and how storing data should be made. Do other data have to be stored permanently or just temporary.

There are probably other solutions to this topic, I have a few on my mind, but don't know it they are applicable to your particular task.

It is generally better to start new post then follow up to older post. 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 6 of 7
olivier.doucet
in reply to: hak_vz

Thanks for your help @hak_vz!
I commented my original post get/set custom DWGPROPS using accoreconsole.exe with extra info about my intent 🙂

Message 7 of 7
john.uhden
in reply to: Anonymous

I think the following functions can be rewritten in plain AutoLisp by substituting dict* functions in place of ActiveX functions (though I haven't done that for you):

But wait, I don't know how to get the activedocument entity via plain AutoLisp.

Oh, I think you can...

(setq props (dictsearch (namedobjdict) "DwgProps"))

Hmm, it seems that DwgProps doesn't exist until a first entry is made, at least in 2002.

(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
)

Note that the ok statements were just my way of finding where I had blundered.  You can eliminate them without any adverse effects.

John F. Uhden

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report