Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
aabfm
Posts: 74
Registered: ‎01-05-2012
Message 1 of 10 (385 Views)

Inserting attribute values into MySQL

385 Views, 9 Replies
01-18-2012 01:31 AM

Hi,

Does anyone know how to connect to MySQL database and insert data from a set of blocks containing attributes?

Something like:

 

block 1:

- x coordinate;

- y coordinate;

- handle;

 

block 2:

- x coordinate;

- y coordinate;

- handle;

 

block 3:

- x coordinate;

- y coordinate;

- handle;


I've just got the second part (retrieving info from the blocks), but when it comes to connect to the DB I'm completely lost.

For the DB I'm using XAMP for Windows, thus using localhost, user ('user123'), pass ('pass123') and table ('table123'). The table has ID (PriKey and AutoInc), px, py and hdl fields.

Thanks in advance.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 10 (370 Views)

Re: Inserting attribute values into MySQL

01-18-2012 05:01 AM in reply to: aabfm

See connection strings here:

http://connectionstrings.com/mysql

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Mentor
stevor
Posts: 836
Registered: ‎12-26-2005
Message 3 of 10 (369 Views)

Re: Inserting attribute values into MySQL

01-18-2012 05:28 AM in reply to: aabfm

You may have to export that data as a text file and then 'import' it into the Xampp.

S
Valued Contributor
aabfm
Posts: 74
Registered: ‎01-05-2012
Message 4 of 10 (364 Views)

Re: Inserting attribute values into MySQL

01-18-2012 09:41 AM in reply to: stevor

That's what I've been doing... :smileysad:

However, in order to make it more automated, I'd like acad to insert the data himself into de DB... :smileywink:

Mentor
stevor
Posts: 836
Registered: ‎12-26-2005
Message 5 of 10 (354 Views)

Re: Inserting attribute values into MySQL

01-18-2012 03:19 PM in reply to: aabfm

As you have neither posted any autocad code, not sql cod, I have no idea where you really are.

It may be possible to link to Xampp as can be done with Excel, etc,

and if that is posted here the try theswamp.org, or google.

 

The most probable 'automatic' means is still:

autolisp makes a file,

then activates a dos or windows script,

which loads it into Xampp.

S
Valued Contributor
aabfm
Posts: 74
Registered: ‎01-05-2012
Message 6 of 10 (348 Views)

Re: Inserting attribute values into MySQL

01-19-2012 12:59 AM in reply to: stevor

In one of my previous posts "Exporting multilayer objects"

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Exporting-list-of-objects/td-p/328363...

 

where Lee_Mac provided the solution, that's exactly what I've been doing: it exports several elements into a txt file and later on a PHP program retrieves the info from it and inserts it into a MySQL DB. That was realy good for the job I was doing at the time.

However, for the one I'm working on, I need pretty much the same but instead of putting the info into a txt file, I need AutoCAD to insert it directly into the DB, since I no longer need the PHP file to perform whatever it was doing at the time.

 

Mentor
stevor
Posts: 836
Registered: ‎12-26-2005
Message 7 of 10 (339 Views)

Re: Inserting attribute values into MySQL

01-19-2012 06:25 AM in reply to: aabfm

If it is the connection side of the process, try that forum:

/discussion.autodesk.com/forum.jspa?forumID=16>

or something 'connectivity.'

 

Also, a 'Seach in this forum finds links.

S
Valued Contributor
aabfm
Posts: 74
Registered: ‎01-05-2012
Message 8 of 10 (338 Views)

Re: Inserting attribute values into MySQL

01-19-2012 07:19 AM in reply to: stevor

During my searches in this forum I found this post MySQL which might be the begining...

Now I just need to insert this code into Lee_Mac's and add some sort of INSERT MySQL command - my next step.

Mentor
stevor
Posts: 836
Registered: ‎12-26-2005
Message 9 of 10 (329 Views)

Re: Inserting attribute values into MySQL

01-19-2012 03:05 PM in reply to: aabfm

Then you must have seen the post by, and of, Jon Fleming, like:

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Jon-Fleming-message-for/td-p/807824/p...

 

His site,  and free AdoLisp, are  still available.

http://www.fleming-group.com

 

S
Valued Contributor
aabfm
Posts: 74
Registered: ‎01-05-2012
Message 10 of 10 (324 Views)

Re: Inserting attribute values into MySQL

01-20-2012 12:53 AM in reply to: stevor

I'll give it a try

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community