Jump to content

Create layer +1


CADEveryDay

Recommended Posts

I am looking to create a routine that will:

1. Select an object in the drawing. (This will predominantly be a rectangle)

2. Take the name of the layer with the selected object (Veiwport_Outline_X)

3. Allow me to copy the object, move to new location, rotate and assign the name 'Veiwport_Outline_X' (X will look within the drawing to find the highest value at the end of the layer Veiwport_Outline_X and +1 to that layer)

 

I have no idea where to start with this. Hats off to anyone who can come up with a solution.

 

Link to comment
Share on other sites

It is all on the internet.

 

So what are your skills with making a LISP, if we give you tips.

Select an object can be done using (entsel) function, something like:

(setq MyEnt (car (entsel "Select Object")))

 

Where entsel will give you the point you clicked and the entity name in a list, car returns the first item in the list, the entity name.

The entity description is made up of dotted pair lists, a descriptor and the value, generally the layer the entity is on is assoc list number 8. So you can get this with

(setq MyLayer (cdr (assoc 8 (entget MyEnt))))

 

Where entget retrieves the dotted pairs lists, assoc 8 finds the one with value '8' and cdr returns the 2nd item of this list, the value or layer name.

 

To copy in this case it might be easiest to use an AutoCAD command, something like this

(command "copy" MyEnt "" pause pause)

 

Where 'Command' tells the program that you are using a standard command, "copy" is the command name (this works with nearly all commands), MyEnt and "" are selecting the items and the pause pause is waiting for user input, the base point and copy to point. You could try the next line similarly with 'rotate' - run the command through the command line and note everything you do. Where you want a mouse input type pause otherwise enter the values you use.

 

Work that part out, the next bits we can look at (entlast) and inserting a sub function to increment the layer name

 

(evening here so CAD is off for the night, but that should be enough to get you started. Post what you make up and we can help with the next parts

Edited by Steven P
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...