Jump to content

Request Lisp PLEASE!- make line and copy position Y, paste it to position Z


Recommended Posts

Posted

OK. I'll give you a hint: you need to use sslength to get the number of objects.

(setq n (sslength ss))

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

  • Stefan BMR

    39

  • ktbjx

    21

  • Tharwat

    2

  • Grrr

    2

Popular Days

Top Posters In This Topic

Posted

Then you can use either

(repeat n  ...

or

(while (< i n) ...

Posted
OK. I'll give you a hint: you need to use sslength to get the number of objects.

(setq n (sslength ss))

what is sslength?

ans isn't it that the setq ss is the object selected?

Posted

Next, save each element into a variable, lets say e.

(setq e (ssname ss i))

Posted

sslength stand for Selection Set Length, and return the number of the objects.

Posted

In order to make any change on the object, you need to get the DXF structure. Each object in the drawing is stored like this, so it's important to learn about DXF.

Posted

The variable el is a list which defines the line. It should look like this:

(
(-1 . <Entity name: 7ff6db706600>)
(0 . "LINE")
(330 . <Entity name: 7ff6db7051f0>)
(5 . "1E8")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbLine")
(10 19.2702 -4.33456 0.0)
(11 20.351 -13.4291 0.0)
(210 0.0 0.0 1.0)
)

Posted

Each sublist is formed by the DXF code, which is the first element, -1, 0, 330 etc.

Posted

The rest is the value of the coresponding DXF code.

Posted

The geometry of the line is defined by it's start (code 10) and by it's end (code 11)

(10 19.2702 -4.33456 0.0)
(11 20.351 -13.4291 0.0)

Posted
The variable el is a list which defines the line. It should look like this:

(
(-1 . <Entity name: 7ff6db706600>)
(0 . "LINE")
(330 . <Entity name: 7ff6db7051f0>)
(5 . "1E8")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbLine")
(10 19.2702 -4.33456 0.0)
(11 20.351 -13.4291 0.0)
(210 0.0 0.0 1.0)
)

 

meaning it has to be defined everytime, so it's on the loop??

 

(while (< i n)
(setq e (ssname ss i))
(setq el (entget e))

(-1 . <Entity name: 7ff6db706600>)
(0 . "LINE")
(330 . <Entity name: 7ff6db7051f0>)
(5 . "1E8")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbLine")
(10 19.2702 -4.33456 0.0)
(11 20.351 -13.4291 0.0)
(210 0.0 0.0 1.0)
)

Posted

So, 10 is DXF code, 19,2702 is the x coordinate, -4.33456 is y and z is 0.0

Posted

Sorry, didnt saw your post.

Posted
Are you still with me?

yes still figuring how you get the coordinated though???

Posted
meaning it has to be defined everytime, so it's on the loop??

 

(while (< i n)
(setq e (ssname ss i))
(setq el (entget e))

 

e and el will be change, because the index must be increased, so each time another entity is stored on e variable, and each will have a different el definition.

Posted

To change the start point, you need to redefine the el list.

First, store old point and the new point:

(setq start_point (assoc 10 el))
(10 19.2702 -4.33456 0.0)

The new point will simply get the y value instead of 0.0

(setq new_start_point (list 10 (cadr start_point) (caddr start_point) (caddr start_point)))
(10 19.2702 -4.33456 -4.33456)

Posted

Sorry, had a typo in the previous post

Posted

To save the el list with the new values:

 

(setq el (subst new_start_point start_point el))
(
(-1 . <Entity name: 7ff6db706600>) 
(0 . "LINE") 
(330 . <Entity name: 7ff6db7051f0>) 
(5 . "1E8") 
(100 . "AcDbEntity") 
(67 . 0) 
(410 . "Model") 
(8 . "0") 
(100 . "AcDbLine") 
(10 19.2702 -4.33456 -4.33456) 
(11 20.351 -13.4291 0.0) 
(210 0.0 0.0 1.0)
)

Posted

Then you do the same with the end point.

(setq el (subst new_end_point end_point el))
(
(-1 . <Entity name: 7ff6db706600>)
(0 . "LINE") 
(330 . <Entity name: 7ff6db7051f0>) 
(5 . "1E8")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbLine")
(10 19.2702 -4.33456 -4.33456)
(11 20.351 -13.4291 -13.4291)
(210 0.0 0.0 1.0)
)

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...