Jump to content

Is it posible to create custom entities/objects using autolisp or visuallisp?


sherby88

Recommended Posts

Hi,

I want to learn autocad programming, and started looking into autolisp and visual lisp.I want to create objects so i can use them for work.

Is it posible to create objects that have custom properties like for example walls, reinforcement bars etc. that have unique attributes/properties that can be used to create a table or even edit them?

And also to be able to double click or select them and bring a custom dialog up (objectdcl or opendcl) with those properties so i can modifie them? (this is not absolutly necesary)

Or this kind of programming can only be achieved using objectARX, VBA, NET?

thx

Link to comment
Share on other sites

The objects i had in mind for the beggining are not complex,

i was thinking in a polyline with leaders and dimensions atached to them and with extra attributes for the info i need from them for tables

and after i learn them good enough to make some 3d objects using them

or if its easier to create blocks and modify them using lisp and link them using reactors.

The reasons i ask these questions are because: i have a good idea of what i want but i dont know what is the best way to go or if its posible with every language.

thx

Link to comment
Share on other sites

You cannot create a custom complex object with lisp or vlisp. Depending on what you want to accomplish you can attach data to objects using block attributes, xdata, xrecord or writing the info to a file. If you just want to read and write data that’s is typically no problem but if you want to change the geometry of an object then it all depends on the type of change and how good you are writing code.

I would suggest writing out the whole thing in pseudo code first. Pseudo code is just plain words on paper like an outline. Write down a step by step in as much detail as possible and also sketch out any dialog boxes. This will help you understand the flow of the project and you will be able to see problem areas and then find answers for the issues.

Example of pseudo code

The user starts my program

Ask the user to pick 2 points

Create a line using users 2 points

Display a dialog box so user can enter data

Dialog box has 2 text boxes for questions (name and date)

Get dialog box data

Use data to attach xdata to line

End program.

Now go back through the pseudo code and make it more detailed if needed and make notes on any questions you might have to research.

Good programming starts with good planning

It is better to spend hours on planning that to spend hours trying to find mistakes in thousands of lines of code.

Link to comment
Share on other sites

thx for the answer

I dont want to create something complex, because i dont have the time for something too complex and time consumming. I'm am structural engineer, not a programmer by profession, but at my company we use generic autocad, not software design for structural detailing, and we dont have interest and money for buying dedicated software because they cost too much.

I only want to speed up the drawings and automate tables process.

At first i wanted to use blocks and using lisp to edit the blocks and the attributes in them.

The only thing i want to know is if i can use lisp to link objects togheter si for example the most important thing i want is:

- I have 3 diffrent objects with their custom properties and if i change one of them they change in other places and in the tables ( for example I number my lines, and these numbers are in 3 to 10 diffrent palces on the drawings). Can I use reactors for this or something?

Link to comment
Share on other sites

If you want to stay with AutoLisp there are many ways to "tag" objects with XDATA. About 13-14 years ago, I worked with someone who did this for steel framing plans. Of course that was back in the day with R14 and with his routines we were able to get a lot of information out of a "2D building model" which acted like a "3D model" when multiple floors were involved. (column schedules, truss and joist schedules, etc.)

My personal opinion is if you use Xdata you need to know exactly what data you would like to save to accomplish your task. I know this statement may seem odd, but knowing what data you want to save with each element is important due to the amount of data you can save with each entity. Secondly, if you know what your output needs to be and how it needs to be displayed, this helps with knowing what types of data to save. No need to save the length of an object when you can extract that information out of the entity list. Abstract thinking helps a bit here.

Let's say you draw a line that is to represent a beam. AutoCAD only knows it's a line object. In adding Xdata you could say this line is a "W8x31" and add this text to your line. You could get as fancy as making a function "TagBeam" which uses a dialog with a dropdown list of wide flange beams for selecting and tagging the line. No ARX required.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...