Jump to content

Add point at the corner of a region


Jord_91
 Share

Recommended Posts

Hi,

     I have some desk drawing and I would like to add some "snap point" at the corner of my desk surface's. As they are in region, when I try using some lisp create by people who select polyline, line and all sort of line it don't work. I have about 20 500 drawing to make.*** I don't want my dwg to be in block because for the next step it won't work.

Here is my dwg in witch i would like to ad point. 3-ML20366620LHRPMPM.dwg

 

Region where I need to add pointManually added point

 

 

 

Thx

 

2019-02-22_09h54_34.png

2019-02-22_09h57_33.png

Link to comment
Share on other sites

Why is the top of the desk comprised of regions?  The top should be a solid.  Despite the fact you used a region it's still possible to use object snaps for picking the corners of the desktop.

 

Upon closer inspection I see that you have used quite the variety of objects to create your desk.  The top of the desk is comprised of eight different regions and one surface.  The legs and front/side panels (six objects) are all solids.  The leveling pads, of which there are six are each comprised of two solids.

I'd suggest making the top a single solid object.  I would also suggest making each leveling pad a single object.  At least this will cut down on the total number of separate entities that go into making up the desk.  Some might argue that the legs and front/side panels be unioned with the top again reducing the number of entities.  This will become very important when the time comes to placing numerous desks in your 3D office building.  Should you have to rearrange the furniture you are less likely to loose or leave behind objects.

Edited by ReMark
Link to comment
Share on other sites

1 hour ago, ReMark said:

Why is the top of the desk comprised of regions?  The top should be a solid.  Despite the fact you used a region it's still possible to use object snaps for picking the corners of the desktop.

 

Upon closer inspection I see that you have used quite the variety of objects to create your desk.  The top of the desk is comprised of eight different regions and one surface.  The legs and front/side panels (six objects) are all solids.  The leveling pads, of which there are six are each comprised of two solids.

I'd suggest making the top a single solid object.  I would also suggest making each leveling pad a single object.  At least this will cut down on the total number of separate entities that go into making up the desk.  Some might argue that the legs and front/side panels be unioned with the top again reducing the number of entities.  This will become very important when the time comes to placing numerous desks in your 3D office building.  Should you have to rearrange the furniture you are less likely to loose or leave behind objects.

ReMark,

              The reason of all these different entities is because of the different layers. As we make some render of our desk we need to have a lot of different layers. Also, My top surface is in regions and surfaces to help for rendering (top color and edge has not the same wood grain).

 

By object snap do you mean doing it manually because it's not an option ( for now I might insert bloc with points at the good place in a script ).

THX

Link to comment
Share on other sites

I was always under the impression different materials could be placed on different faces of 3D models.  You are implying that this is not the case.

I see no reason for the edges and underside of the top of the desk to be separate objects.

You want to insert desks relative to a point (or points) located on the top of the desk by script into one or more drawings.  Is this what you are attempting to accomplish?

Link to comment
Share on other sites

Maybe something like this:

(defun KGA_List_DuplicateRemoveAllEqual (lst fuzz / ret)
  (mapcar
    '(lambda (a)
      (if
        (vl-every
          '(lambda (b) (not (equal a b fuzz)))
          ret
        )
        (setq ret (cons a ret))
      )
    )
    lst
  )
  (reverse ret)
)

(defun KGA_Sys_ObjectOwner (obj)
  (vla-objectidtoobject (vla-get-database obj) (vla-get-ownerid obj))
)

(defun c:RegionPoints ( / doc enm objLst ptLst reg spc)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (if
    (and
      (setq enm (car (entsel "\nSelect region: ")))
      (setq reg (vlax-ename->vla-object enm))
      (= "AcDbRegion" (vla-get-objectname reg))
    )
    (progn
      (setq objLst (vlax-invoke reg 'explode))
      (setq spc (KGA_Sys_ObjectOwner (car objLst)))
      (setq ptLst
        (KGA_List_DuplicateRemoveAllEqual
          (apply
            'append
            (mapcar
              '(lambda (obj)
                (if (vlax-property-available-p obj 'startpoint)
                  (list
                    (vlax-get obj 'startpoint)
                    (vlax-get obj 'endpoint)
                  )
                )
              )
              objLst
            )
          )
          1e-8
        )
      )
      (mapcar 'vla-delete objLst)
      (foreach pt ptLst
        (vla-addpoint
          spc
          (vlax-3d-point pt)
        )
      )
    )
  )
  (vla-endundomark doc)
  (princ)
)

 

Link to comment
Share on other sites

5 minutes ago, ReMark said:

I was always under the impression different materials could be placed on different faces of 3D models.  You are implying that this is not the case.

I see no reason for the edges and underside of the top of the desk to be separate objects.

You want to insert desks relative to a point (or points) located on the top of the desk by script into one or more drawings.  Is this what you are attempting to accomplish?

In fact, I made some Wblocks of the files containing the 4 -5-6 corners already placed and, as there's some dimension that'sbeen the same, I will be able to -insert bloc in the selected drawing. But it's a lot of handling which increase the chances of errors...

Link to comment
Share on other sites

23 minutes ago, Roy_043 said:

Maybe something like this:


(defun KGA_List_DuplicateRemoveAllEqual (lst fuzz / ret)
  (mapcar
    '(lambda (a)
      (if
        (vl-every
          '(lambda (b) (not (equal a b fuzz)))
          ret
        )
        (setq ret (cons a ret))
      )
    )
    lst
  )
  (reverse ret)
)

(defun KGA_Sys_ObjectOwner (obj)
  (vla-objectidtoobject (vla-get-database obj) (vla-get-ownerid obj))
)

(defun c:RegionPoints ( / doc enm objLst ptLst reg spc)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (if
    (and
      (setq enm (car (entsel "\nSelect region: ")))
      (setq reg (vlax-ename->vla-object enm))
      (= "AcDbRegion" (vla-get-objectname reg))
    )
    (progn
      (setq objLst (vlax-invoke reg 'explode))
      (setq spc (KGA_Sys_ObjectOwner (car objLst)))
      (setq ptLst
        (KGA_List_DuplicateRemoveAllEqual
          (apply
            'append
            (mapcar
              '(lambda (obj)
                (if (vlax-property-available-p obj 'startpoint)
                  (list
                    (vlax-get obj 'startpoint)
                    (vlax-get obj 'endpoint)
                  )
                )
              )
              objLst
            )
          )
          1e-8
        )
      )
      (mapcar 'vla-delete objLst)
      (foreach pt ptLst
        (vla-addpoint
          spc
          (vlax-3d-point pt)
        )
      )
    )
  )
  (vla-endundomark doc)
  (princ)
)

 

Hi your lisp is working fine but is there a way that I could select everything (ai_selall) and then start your lisp instead of startin it and select only the available region (I would like to be able to use it in a script). Still it's pretty much what I need the lisp to do 😃!!! 

 

Thx

Link to comment
Share on other sites

In the provided drawing there are a number of regions. From your description I conclude that you only want to add these point entities for the region that represents the top of the desk, and not for the other regions. Is this correct and does the same apply to all other drawings?

Link to comment
Share on other sites

2 hours ago, Roy_043 said:

In the provided drawing there are a number of regions. From your description I conclude that you only want to add these point entities for the region that represents the top of the desk, and not for the other regions. Is this correct and does the same apply to all other drawings?

You’re quite right except that the only regions in the drawing are on te top there is no other regions in my drawing. So even if I pick everything and it adds point in every corners it will be just as perfect!

Link to comment
Share on other sites

Placing a point on every unique vertex of every region does result in 14 point entities in the sample drawing. The code below will do that, but I am not sure if that is actually what you want. Note: the points are created on the current layer. So in your script you should take care to make the correct layer current before running the code.

(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)
  (if ss
    (repeat (setq i (sslength ss))
      (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))
    )
  )
)

(defun KGA_List_DuplicateRemoveAllEqual (lst fuzz / ret)
  (mapcar
    '(lambda (a)
      (if
        (vl-every
          '(lambda (b) (not (equal a b fuzz)))
          ret
        )
        (setq ret (cons a ret))
      )
    )
    lst
  )
  (reverse ret)
)

(defun RegionPointList (reg / objLst ptLst) ; Reg as vla-object.
  (setq objLst (vlax-invoke reg 'explode))
  (setq ptLst
    (KGA_List_DuplicateRemoveAllEqual
      (apply
        'append
        (mapcar
          '(lambda (obj)
            (if (vlax-property-available-p obj 'startpoint)
              (list
                (vlax-get obj 'startpoint)
                (vlax-get obj 'endpoint)
              )
            )
          )
          objLst
        )
      )
      1e-8
    )
  )
  (mapcar 'vla-delete objLst)
  ptLst
)

(defun c:RegionPoints ( / doc spc ss) ; Places a point on every unique region vertex in modelspace.
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (if (setq ss (ssget "_X" '((0 . "REGION") (410 . "Model"))))
    (progn
      (setq spc (vla-get-modelspace doc))
      (foreach
        pt
        (KGA_List_DuplicateRemoveAllEqual
          (apply
            'append
            (mapcar
              'RegionPointList
              (KGA_Conv_Pickset_To_ObjectList ss)
            )
          )
          1e-8
        )
        (vla-addpoint
          spc
          (vlax-3d-point pt)
        )
      )
    )
  )
  (vla-endundomark doc)
  (princ)
)

 

Edited by Roy_043
Link to comment
Share on other sites

BTW: The adjustable feet with their high level of detail (helical threads) make the model unnecessarily 'heavy'.

Edited by Roy_043
Link to comment
Share on other sites

One problem with putting points in the corners of the top of the desk is if the desks, which are not blocks, are moved, rotated, copied, mirrored, etc. then you'll have to be sure to select all the points as well.  Chances are some points may be missed. 

Link to comment
Share on other sites

19 hours ago, ReMark said:

"Unnecessarily heavy"?  How so?

Maybe you have a 'fat' computer, but opening the dwg and, especially, changing the view are relatively slow operations on my system. Erasing the feet will reduce the file size to ca. 100kB, and the time it takes to open the file from ca. 3s to less than 1s. Since the feet are hardly visible I would simplify them. Perhaps they should also be block references.

Link to comment
Share on other sites

My home computer is 9 years old consisting of an AMD Phenom II 945, 3.0GHz (quad core), 8B DDR3 1066 dual channel memory, ATI Radeon HD 4870 1GB graphics card running Win7 Ultimate and AutoCAD 2018.  Had no problems viewing, editing or manipulating in any way the 3D desk model.  I do agree that simplifying the leveling feet would be a good idea.

Link to comment
Share on other sites

Remark, I had the question once on some custom software dwg of a window please zoom in, did so,  why can we not see the timber moulding, well the plan shows two paralell lines for the window edge for the window maufacturer ,thats all they want add a note somewhere or a detail dwg of the moulding ! Oh yeah is the thread on the leg support metric or imperial and what size ? 🤣 Like you my old I3 laptop grinds a bit but I am mainly responding to Cadtutor so not a problem.

 

I agree the top as a solid much easier.

 

Jord_91 do you have some custom lisps to draw the tables ? Massive time savings can be achieved.

Edited by BIGAL
Link to comment
Share on other sites

On 2/23/2019 at 10:25 AM, ReMark said:

One problem with putting points in the corners of the top of the desk is if the desks, which are not blocks, are moved, rotated, copied, mirrored, etc. then you'll have to be sure to select all the points as well.  Chances are some points may be missed. 

I understand your concern about block. The only reson why I’m not using block is that all that drawing will be « scrubber » ( wich create polyface3D and then I send it to an outside company wich use it to create a Catalogs with all our furniture. It will help our costumer to make their own setup ( in block made by the outside company ). 

Link to comment
Share on other sites

14 hours ago, BIGAL said:

Remark, I had the question once on some custom software dwg of a window please zoom in, did so,  why can we not see the timber moulding, well the plan shows two paralell lines for the window edge for the window maufacturer ,thats all they want add a note somewhere or a detail dwg of the moulding ! Oh yeah is the thread on the leg support metric or imperial and what size ? 🤣

 

I agree the top as a solid much easier.

 

Jord_91 do you have some custom lisps to draw the tables ? Massive time savings can be achieved.

All m’y drawing are done (spend 4monts on 20 500 drawing) except that we didn’t knew while we were doing it that we would need points in the 3d drawing for another which can use our drawing. I made a lot of script to change legs, to add pedestal etc... (It has savedme a lot of time). I clearly would have loved to put top in solid but we mist be able to make représentative rendering (customer concern) and the programs that our customer use is a bit shitty (my point of view) they are not all having 3D drawing computer with great grapic card.

Edited by Jord_91
Link to comment
Share on other sites

On 2/23/2019 at 3:59 AM, Roy_043 said:

Placing a point on every unique vertex of every region does result in 14 point entities in the sample drawing. The code below will do that, but I am not sure if that is actually what you want. Note: the points are created on the current layer. So in your script you should take care to make the correct layer current before running the code.


(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)
  (if ss
    (repeat (setq i (sslength ss))
      (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))
    )
  )
)

(defun KGA_List_DuplicateRemoveAllEqual (lst fuzz / ret)
  (mapcar
    '(lambda (a)
      (if
        (vl-every
          '(lambda (b) (not (equal a b fuzz)))
          ret
        )
        (setq ret (cons a ret))
      )
    )
    lst
  )
  (reverse ret)
)

(defun RegionPointList (reg / objLst ptLst) ; Reg as vla-object.
  (setq objLst (vlax-invoke reg 'explode))
  (setq ptLst
    (KGA_List_DuplicateRemoveAllEqual
      (apply
        'append
        (mapcar
          '(lambda (obj)
            (if (vlax-property-available-p obj 'startpoint)
              (list
                (vlax-get obj 'startpoint)
                (vlax-get obj 'endpoint)
              )
            )
          )
          objLst
        )
      )
      1e-8
    )
  )
  (mapcar 'vla-delete objLst)
  ptLst
)

(defun c:RegionPoints ( / doc spc ss) ; Places a point on every unique region vertex in modelspace.
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (if (setq ss (ssget "_X" '((0 . "REGION") (410 . "Model"))))
    (progn
      (setq spc (vla-get-modelspace doc))
      (foreach
        pt
        (KGA_List_DuplicateRemoveAllEqual
          (apply
            'append
            (mapcar
              'RegionPointList
              (KGA_Conv_Pickset_To_ObjectList ss)
            )
          )
          1e-8
        )
        (vla-addpoint
          spc
          (vlax-3d-point pt)
        )
      )
    )
  )
  (vla-endundomark doc)
  (princ)
)

 

 

If I would have put my drawing in block was it easier to spot the corner for you? I might just explode last after all. 

 

BTW Thx a lot

Edited by Jord_91
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
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.

 Share

×
×
  • Create New...