Jump to content

Recommended Posts

Posted

Hello, everything is fine?

 

I'm trying to create a situation, which I believe is a bit impossible, but it doesn't hurt to try lol.

 

I have a template with about 10k objects (I'll call them Draw1), among which many are repeated, because I try to make future drawings similar to those in the template.

 

As I work with topography, where coordinates are extremely important, I always start a drawing as follows:
1) I open the DWG of the new drawing, copy all the objects it contains
2) I open the template drawing that has 10k objects (Draw1)
3) Use Edit > "Paste to Original Coordinates"
4) I use the "CUTCLIP" function on the 10k objects (Draw1)
5) I use Zoom extents to frame the drawing with me, because they are always in very distant coordinates from the initial one (Origin 0).
6) I use paste and position Draw1 around the new drawing.

 

This is a routine that I need to do in all my drawings, but it takes me a lot of time having to repeat this process every time. I tried to create the following lisp routine, but no movement is performed. Can anyone shed some light?

 

 

 

Quote

(defun c:PasteAndMove (/ objSel offset TX i)
  (setq objSel (ssget "_X" '((0 . "INSERT"))))
  (setq offset 10000.0) ; Offset distance in millimeters (10 meters)
  
  (if objSel
    (progn
      (command "_pasteorig")
      (setq TX (ssadd))
      (setq i 0)
      
      (while (< i (sslength objSel))
        (setq obj (vlax-ename->vla-object (ssname objSel i)))
        (setq TX (ssadd (vlax-vla-object->ename obj) TX))
        (setq i (1+ i))
      )
      
      (setq i 0)
      
      (while (< i (sslength TX))
        (setq obj (vlax-ename->vla-object (ssname TX i)))
        (vla-move obj (vlax-3D-point 0.0 offset 0.0))
        (setq i (1+ i))
      )
      
      (princ "Objects pasted and moved.")
    )
    
    (princ "No objects to paste.")
  )
  
  (princ)
)
 

 

Posted

Are you trying to move all blocks from origin '(0. 0. 0.) to that custom destination '(0.0 10000.0 0.0) ?

Posted

I'll try to explain with another formula.

 

Whenever a land measurement arrives (Topography), line data, objects, texts, etc., come in fixed coordinates because they are associated with a certain place on the map, correct?

 

For example 551132735, 641072441

 

My template drawings are at coordinate 0. I wanted to open the template drawing with the 10k objects, use "pasteorig" because that way the original objects are taken to the proper coordinate, after that the template drawings (draw1) are cut or moved next to pasted topographic drawings.

 

Example:

 

Quote

(defun c:pt ()
(setq ss (ssget "_X" (list (cons 8 "(01) NCW TEMPLATE"))))
        (command "_pasteorig")
        (command "_.CUTCLIP" ss "")
        (command "_zoom" "e")
        (command "_pasteclip" pause)

  (princ)
)

 

Posted (edited)

If I understand correctly, we would open a dwg then ctrl+a which copies the model dwg objects to the clipboard, then open our master template and paste to original co-ordinates. This way correct layers and blocks are available for use. We did not have anything exposed in model space of our master template like blocks and line types.

 

Ok but you want all this other stuff that you have as dwg objects in another dwg so you can copy and use it, so easy dont paste to original rather use  -insert and paste to the right of the original dwg, easy part is (getvar 'extmax) returns top right corner of the existing dwg. So you insert your other dwg full of objects to say +100 in the X direction of extmax, then explode once, its ready to use. 

image.png.ddfb241b86c28e5b84ae4994d0d47c26.png

(defun insertstddtetails ( / maxpt)
(setq maxpt (getvar 'extmax))
(setq maxpt (mapcar '+ maxpt (list 100 100 0.0)))
(command "-insert" "STD details SEP 22" "S" 1 maxpt 0.0)
(command "explode" (entlast))
(command "zoom" "E")
)
(insertstddtetails)

 

Edited by BIGAL
Posted

This insert idea is great, because you don't have to make a lot of effort to receive another file. The only situation that makes me not follow this path is that I receive drawings coming from other settings (Layer, Color, Linetype, Lineweight, Font, Block), so when I open the drawing template (Draw01) and bring these objects that I will work with (DrawNew), as the objects are set ByLayer, they all change according to my template drawing.

 

That's why I need to open the drawings I'm going to work on (DrawNew), copy all the objects, open the drawing template (Draw01), put it in pasteorig so that the objects (DrawNew) go to their correct coordinates, then I need to bring the objects in my template close by moving or copying and pasting close to DrawNew.

 

I tried this code 

Quote

(defun c:pt ()
(setq ss (ssget "_X" (list (cons 8 "(01) NCW TEMPLATE"))))
        (command "_pasteorig")
        (command "_.CUTCLIP" ss "")
        (command "_zoom" "e")
        (command "_pasteclip" pause)

  (princ)
)

 

But it's so initial and don't give me a distance between DrawNew and Draw01, like offset 10000

Posted

"bring the objects in my template close by" these objects are in a separate dwg not necessarily the master template. Like above "STD details SEP 22.dwg". This was done for projects where government standards must be met, v's a normal client dwg using company standards.

Posted

I believe is more better to explain by video, right?

 

So see below a ilustrative video about what I want to do (See attached).

 

1) I open the drawing that I will work on (DrawNew)

2) I show that every layer is blank, just with names

3) I copied all objects

4) I Open the Template Drawing (Draw1)

5) I show how the template need be, with colors, linetypes etc

6) I used "pasteorig" to paste the objects (DrawNew) on Template Drawing (Draw1) without loosing the co-ords

7) I used Zoom Extents

8 ) I used "Cutclip" on Template Drawing (Draw1) and bring close to the drawing that I will work next

9) I used paste to set next to the DrawNew

10) I set every object as ByLayer

 

I would like to have a lisp routine like that, but I have no idea how to do that. Any ideas?

Posted

I think I posted elsewhere, make a new dwt with all your layers, styles and linetypes in it no dwg objects.

Step 1 copy the original world dwg into this template then layers etc should be correct.

Step 2 insert and explode your objects dwg at extmax+100 as previously posted.

 

The way we did it was to use a library of dwg objects and insert when required. This was via a pop menu that had the objects in categories like "3d furniture". 

4x4.png.652d6b2a5359341624637a8d81c1a71f.png

 

The pop menu is easy to make as you just use Notepad.

menu2.png.31566e48b6a2d6983b201aef0e2412c0.png

As you can see the Next page is available, when you exceed 20 objects. I find it easier than the Acad insert block function that displays all your blocks. 

 

The other way is to look at Tool Palettes. Others will comment about this, but it does what you want to get an object from another dwg.

 

With both methods the blocks do not have to exist in the dwg they can be brought in from another dwg or as a single dwg. Explorer shows.

image.thumb.png.e0e2a3c0728ccb06d6b11df34a553a75.png

 

 

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