lmorse Posted November 22, 2020 Posted November 22, 2020 Hi, I am have a database containing object information. I am able to write out a script from my database that inserts blocks into Autocad C3D. Here is an example of the script file: osmode 0 -layer Set "2020_DESIGN" ATTREQ 1 ATTDIA 0 -insert "DESIGN" 607476.547,7574318.945,0 1 1 0 GAS GR04L001 10354 Is there a way that I can also insert Object Data (into a data table) using this script when creating the block? I have attached an image showing the structure of the data table that I would like to populate. Thanks in advance Lee Quote
BIGAL Posted November 23, 2020 Posted November 23, 2020 If your doing lots of insert look at a lisp Must it be Object data ? Why not invisible attributes much easier. ade_odsetfield - AutoCAD Map 3D AutoLISP Documentation Not sure about adding to block this is an example of get data. ; simple object data example ; By Alan H July 2019 (defun c:odtest ( / ent ty odname dia material) (setq ent (car (entsel "\n Select Polyline (or press Enter to Exit): "))) (setq ty (cdr (assoc 0 (entget ent)))) (if (and (eq "LWPOLYLINE" ty) (/= (setq odname (ade_odgettables ent)) nil) ) (progn (setq dia (ade_odgetfield ent odname "Diameter" 0)) (setq mat (ade_odgetfield ent odname "Material" 0)) (alert (strcat "Material: " mat " \nDiameter " (rtos dia 2 2) (chr 34) " Main")) ) ) (princ) ) (c:odtest) Quote
lmorse Posted November 24, 2020 Author Posted November 24, 2020 Hi, Thanks for your reply. Unfortunately, yes it MUST be object data (a statutory requirement). While I have done plenty of VBA coding, I am unfamiliar with LISP - I find it quite hard to read. I will need to brush up on this. Not sure the boss will wait for me to learn LISP for a solution though Quote
steven-g Posted November 24, 2020 Posted November 24, 2020 Does anything here help. It is possible using a script but you can only pick table cells by entering coordinates so it would take a bit of study to create a working script. Quote
lmorse Posted November 24, 2020 Author Posted November 24, 2020 1 hour ago, steven-g said: Does anything here help. It is possible using a script but you can only pick table cells by entering coordinates so it would take a bit of study to create a working script. This looks like its for a table, not Object Data? Quote
steven-g Posted November 25, 2020 Posted November 25, 2020 Sorry my bad I just spotted 'C3D' in you question there is a dedicated forum for civil which might get you a more targeted answer. Quote
BIGAL Posted November 26, 2020 Posted November 26, 2020 Google object data VBA AUTOCAD. Should be examples. Look at "Diameter " & "Material" replace with ASSET_TYPE & DATE_SURVEYED in example. Quote
lmorse Posted November 26, 2020 Author Posted November 26, 2020 (edited) Hi BIGAL, Quote Google object data VBA AUTOCAD. Should be examples. Look at "Diameter " & "Material" replace with ASSET_TYPE & DATE_SURVEYED in example. I have Googled your suggestion, but I'm embarrassed to say I have no idea where to start with any of this. The best I can discern is that there is some kind of VBA add-on for AutoCad? At a loss.... Edited November 26, 2020 by lmorse Quote
BIGAL Posted November 27, 2020 Posted November 27, 2020 In Autocad you just type VBAMAN this will open VBA you can load or write new code. Much the same as in excel Macros. You simply VBALOAD a dvb then VBARUN the subroutine etc so in this example is a vba with lots of sub functions. The code snippet is lisp to run the PROJECTNO command. (defun C:projectno () (vl-vbaload "P:/AutoDESK/VBA/Design Toolkit.dvb") (vl-vbarun "add_project_number") ) I found this example a couple of problems its based around 2004, version number will need to find current number Not tested 2020 is 23 ? Quote
Recommended Posts
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.