Jump to content

Recommended Posts

Posted

This one should be easy for you lisp guru's.

 

I would like an example of how to use entmake to make a continouse element such as a line.

 

I am unsure how to keep the entmake going as I select points to create my line from point to point.

 

Also, how do I show the line as I pick the next point?

 

This is a studying question, it has no baring on any macro that I am creating as of yet.

 

Thanks

Posted (edited)

eg.

(defun AT:DrawLines (/ lst pt eLst)
 ;; Alan J. Thompson, 08.20.10
 (if (car (setq lst (list (getpoint "\nSpecify first point: "))))
   (while (setq pt (getpoint (car lst) "\nSpecify next point: "))
     (setq eLst (cons (entmakex (list '(0 . "LINE")
                                      (cons 10 (trans (car lst) 1 0))
                                      (cons 11 (trans (car (setq lst (cons pt lst))) 1 0))
                                )
                      )
                      eLst
                )
     )
   )
 )
 (reverse eLst)
)

Edited by alanjt
Posted

Thanks Alan

 

What does the AT: Mean/do? I have not seen this yet. since I don't know what it means I changed it to C: so I could test it in ACAD (and it worked fine) but curiouse as heck to know what AT: is.

 

 

I was looking up entmakex and found another post by you at augi. Just learned something esle from you, I had no idea I could highlight the command then hit the questionmark and it would take me to the definition of the command, this is great....

 

But I am still a little unsure what it is telling me

 

entmakex: Makes a new object or entity, gives it a handle and entity name (but does not assign an owner), and then returns the new entity name. What does this mean?

 

I am guessing that it is creating the multiple entities (the lines) but I don't know what owner is?

 

Is trans the command that allows me to see the line as I draw it? I am reading that it has to do with the coordinate system but I don't see a flag that will make it display and I don't see any thing else that pops out at me to make it display as I draw.

 

What part of this lisp make the line display as I draw it.

 

Thanks

Posted

Sorry if I am stepping on your toes Alan, but I was eager to answer :)

 

What does the AT: Mean/do? I have not seen this yet. since I don't know what it means I changed it to C: so I could test it in ACAD (and it worked fine) but curiouse as heck to know what AT: is.

 

AT = Alan Thompson

 

Developers sometimes use prefixes such as these to label their subfunctions as their own.

 

entmakex: Makes a new object or entity, gives it a handle and entity name (but does not assign an owner), and then returns the new entity name. What does this mean?

 

I am guessing that it is creating the multiple entities (the lines) but I don't know what owner is?

 

Entmakex adds the entity information to the drawing database and can be used to create drawing objects, layers, blocks, etc etc.

 

The owner is the object in which the enitities are contained, for example graphical entities are contained in the Modelspace/Paperspace Block Objects and entities that make up a block (insert) are contained in that Block Definition Object.

 

The fact that entmakex does not assign an owner means that you can create entities under various owners such as the Document Object (contains Layers/Block Definitions/Linetypes etc), or perhaps the ModelSpace/Paperspace Block Objects (contains graphical entities) etc.

 

Is trans the command that allows me to see the line as I draw it? I am reading that it has to do with the coordinate system but I don't see a flag that will make it display and I don't see any thing else that pops out at me to make it display as I draw.

 

Trans allows for if the user is utilising a UCS (User Coordinate System) other than WCS (World Coordinate System). This is a huge subject to explain here, but in laymans terms: when using entmakex to create a line or point, for example, the points that make up the data must be specified in WCS, so any UCS points that are selected by the user on screen must be transformed to WCS (either by a transformation matrix, or the trans function).

 

However, this method of transformation varies from object to object, as entities such as lines/points do not define a plane, and hence are specified in WCS with their Normal Vector (dxf 210) derived using the Arbitrary Axis Algorithm. But entities such as LWPolylines, etc that do lie in a plane have their own OCS (Object Coordinate System) in the plane in which they are drawn (may be different from both UCS and WCS), and hence the point data must be transformed to this coordinate system through use of an entity name or normal vector in that plane.

 

What part of this lisp make the line display as I draw it.

 

Take a closer look at the getpoint function, it can take an extra point argument to rubber-band between points.

Posted
Sorry if I am stepping on your toes Alan, but I was eager to answer :)

LoL Clearly.

Nah, it's fine by me, less I have to type; I've got my hands full with my girls, anyway. :)

Posted
LoL Clearly.

Nah, it's fine by me, less I have to type; I've got my hands full with my girls, anyway. :)

 

Cool stuff - have a good weekend mate. :)

Posted
Cool stuff - have a good weekend mate. :)
You too. :)
Posted

Wow, Dr. Lee Mac has held class today!:acad:

 

You should help Autodesk rewrite parts of the VLISP Developer Help sections. I can read yours once and "Get It". I often read theirs several times and, well, still don't "Get It".

Posted
Wow, Dr. Lee Mac has held class today!:acad:

 

You should help Autodesk rewrite parts of the VLISP Developer Help sections. I can read yours once and "Get It". I often read theirs several times and, well, still don't "Get It".

 

Thanks, I'm glad you could glean something from my post - of course, this is only what I have learnt in my time programming for CAD - I welcome any corrections to the information I have given.

 

Lee

Posted

Alan,

 

Just a nit pick on my part:

 

By using the (trans) call, I would assume ( that's what gets me in trouble with my wife ) that you've anticipated that the USC settings aren't always WCS during input. I like that. I would suggest adding (cons 210 (trans '(0 0 1) 1 0)) so that if thickness is set to anything other than 0.0, the lines would display correctly. Unlike some others groups that default to their current respective sysvar settings, 210 defaults to WCS '(0 0 1) in (entmake)

 

ADESK was not very consistent when they created entmake. DXFIN defaults to different settings for 6, 39, 48, 62, 210 ( That I know of anyway )

 

My $0.02 -David

Posted

Thanks Lee Mac

 

I found the rubberband (car lst), can I assume that this will work with most anything, such as move and copy? (not skilled enough yet to quickly write one up to test it, just curiouse if it works off the same idea)

 

I still don't understand the difference between entmake and entmakex (I am sure this will become much clearer as time passes and get more exposure but for now, huhhhh?)

Why would you need an owner or what would be a good example of why you would need an owner (this is still above my head)

 

 

David's reply helped me understand the trans a bit more along with your explanation. I can't assume the user is using WCS during input (this was a huge clue for me to understand) and lines and points are just that, points on a WCS where a line is nothing more than an entity between those two points defined by the dxfcode.

 

I can understand that lwpolylines have their own OCS coordinate system. They are more like free floating elements in space, where they are controled more by parameters. (I am making this up as go, trying to find a path of logic) but this element still needs to be placed initially on a WSC coordinate defined by the dxfcode, right? I am asking because I still have to define a dxf code 10 for points when creating a lwpolyline

 

 
(setq obj (list
      (cons 0 "lwpolyline")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 8 "0")
      (cons 43 0)
      (cons 90 4)
      (cons 70 1)
      (cons 10 pt1)
      (cons 10 pt3)
      (cons 10 pt2)
      (cons 10 pt4)
      )
)

Posted
I found the rubberband (car lst), can I assume that this will work with most anything, such as move and copy? (not skilled enough yet to quickly write one up to test it, just curiouse if it works off the same idea)

 

Look at the help on such functions as getpoint / getdist etc, and check the arguments.

 

I still don't understand the difference between entmake and entmakex (I am sure this will become much clearer as time passes and get more exposure but for now, huhhhh?)

Why would you need an owner or what would be a good example of why you would need an owner (this is still above my head)

 

The main difference between entmake and entmakex is that entmakex returns the entity name upon creation, whereas entmake returns the entity's dxf data list. The owner is the object in which other objects are contained so to speak, the hierarchy (ActiveX COM Model) becomes clearer when you study Visual LISP or VBA.

 

David's reply helped me understand the trans a bit more along with your explanation. I can't assume the user is using WCS during input (this was a huge clue for me to understand) and lines and points are just that, points on a WCS where a line is nothing more than an entity between those two points defined by the dxfcode.

 

The way I look at it is that entities such as lines or points cannot define a plane, and hence must be drawn in WCS.

 

I can understand that lwpolylines have their own OCS coordinate system. They are more like free floating elements in space, where they are controled more by parameters. (I am making this up as go, trying to find a path of logic) but this element still needs to be placed initially on a WSC coordinate defined by the dxfcode, right? I am asking because I still have to define a dxf code 10 for points when creating a lwpolyline

 

LWPolylines lie in a plane, defined by their normal vector (group 210) and hence the coordinates of the vertices are defined in the coordinate system of this plane (the OCS). I believe the normal vector itself is defined in WCS.

 

Lee

Posted

You have given me enough guidence for me to find my way, Thanks Lee

Posted
You have given me enough guidence for me to find my way, Thanks Lee

 

You're very welcome CADman :)

Posted

Lee,

 

Lines can define an OCS. Lines ( 2D or 3D ) with thickness display as a plane. Their points are always stored WCS, but once thickness has been applied, it can be conceptualized fairly easily:

 

(entmake (list (cons 0 "LINE")
              (cons 39 4)
              (cons 10 (list 5 9 2))
              (cons 11 (list 8 12 5))
              (cons 210 (list 0.26726124 0.53452248 0.80178373))))

 

 

[b][color=BLACK]([/color][/b]defun line-ocs [b][color=FUCHSIA]([/color][/b]en / ed p10 p11 thk ecs p20 p21[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq ed [b][color=NAVY]([/color][/b]entget en[b][color=NAVY])[/color][/b]
       p10 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 10 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       p11 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 11 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       thk [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 39 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       ecs [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 210 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]or thk [b][color=NAVY]([/color][/b]setq thk 0[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq ExtTk [b][color=NAVY]([/color][/b]mapcar '[b][color=MAROON]([/color][/b]lambda [b][color=GREEN]([/color][/b]x[b][color=GREEN])[/color][/b] [color=#8b4513];;ExtDir[X] * tk[/color]
                       [b][color=GREEN]([/color][/b]* x thk[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [color=#8b4513];;ExtDir[Y] * tk[/color]
                            ecs[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [color=#8b4513];;ExtDir[Z] * tk[/color]
 [b][color=FUCHSIA]([/color][/b]setq p20 [b][color=NAVY]([/color][/b]mapcar '+ ExtTk p10[b][color=NAVY])[/color][/b]
       p21 [b][color=NAVY]([/color][/b]mapcar '+ ExtTk p11[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons  0 [color=#2f4f4f]"3DFACE"[/color][b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]assoc 8 ed[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 10 p10[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 11 p20[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 12 p21[b][color=MAROON])[/color][/b]
                [b][color=MAROON]([/color][/b]cons 13 p11[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

Points are the same just a bit harder to visualize. -David

Posted

Thanks David - I guess I was just trying to explain why lines/points have their coords in WCS, whereas LWPolys etc are in OCS.

 

But many thanks for the info, appreciated. :)

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