Jump to content

Recommended Posts

Posted

I am trying to figure out how create a copy of a selection set on the next layer suffix progression.

I did look into the copytolayer command but I am not sure how to continue the suffix of the original layer.

 

 

The user selects the objects (rectangle for example). Hits Enter.

The command would create a new Layer (If the selected layer is Viewport_1) It would copy the objects to a new layer (Viewport_2), etc.

Again if the Layer is (Viewport_22) it would create a new layer (Viewport_23).

 

Please let me know if that is doable or not. Thank you for any direction.

 

 

Posted (edited)

Say "Viewport_22" is the layer, but there are no "Viewport_20" or "Viewport_21" or even "Viewport_10" will it stil go to the next number "Viewport_23" ?

I is always best to show on a drawing file what the final product is. 

 

EDIT:

Also, if "Viewport_23" already exist which means there may or may not be an object already assign to that layer. will it go to the next number "Viewport_24"

 

 

 

Edited by pBe
Posted (edited)

Yup you are right. That's the idea. I would select a rectangle that would be on layer 11, then it would copy it to the next layer 12 (even if layer 12 is there).

 

Edited by rcb007
Posted

And if the selected rectangle's layer does'nt have a number? 

Posted

If it does not have a number, would it be possible to have the rectangle be copied to a new layer name (Layer 1)?

Posted (edited)
4 minutes ago, rcb007 said:

If it does not have a number, would it be possible to have the rectangle be copied to a new layer name (Layer 1)?

 

Be copied or rename the layer with "_1" suffix?

 

Wait a minute, you did not answer the "skipping" number query?

 

Edited by pBe
Posted (edited)

Im sorry, what I mean is that the rectangle on "Layer without a suffix" would need to be moved to a new "Layer 1".

 

I would like the layers names be the viewport areas names. (Example Layer names would be similar to, Matchline Area 1, Matchline Area 2, etc)

Edited by rcb007
Posted

So the answer is YES, it is doable. :)

 

 

Posted

Yes please. lol Im sorry its Monday!

Posted

Now how's about posting a drawing sample rcb007

===================================================================================

- Are you planning to use this ONLY for viewports? How many layouts / Viewports are there in your drawing?

- Does the new layer inherits the source layers properties? color and all? (Attack of the clones)

- Is it a single object selection mode?

 

===================================================================================

- to clarify, regardless in a number is "avaialble"|, the new layer number will always be the next number?

- A layer with no number prefix will be left alone and the program will create a new layer with suffix 1, meaning  current: VP  new: VP 1 ,and NOT rename VP to VP 1?

- Use space as delimiter and not "-" or "_" ?

 

 

 

 

 

 

Posted

Yes this dwg I would like to use as my master viewports and layouts only.

Usually 1 viewport per layout tab.

Amount of layout tabs will vary depending on the scale.

 

Yes the new layer would be cloned.

 

The selection is usually a few objects. (2 rectangles and maybe text of the viewport name)

 

The new layer number will always be the next number.

 

I think the VP would remain, but the Objects be moved to VP 1 (Not to rename Layer VP)

 

I think the delimiter would be case by case, Sometimes, "VP_1" to "VP 1" to "VP-1".

 

Here is an example dwg.

 

 

Viewport Layer test.dwg

Posted

Nice, All you need now is someone to write a code for this. :)

 

I'll see what i can do.

 

Maybe you'll get lucky some one else can jump in that has a code at-the-ready.

Be patient rcboo7

 

Posted

Not a prob. Thank you for helping me thoroughly think this through!

Posted (edited)

HYG

(defun c:demo (/ AttackOFTheClones _toNumb el ss cly nly)
  (defun AttackOFTheClones (cur nw / d)
    (if	(setq tbc (entget (tblobjname "LAYER" cur)))
      (entmake (append
		 (list '(0 . "LAYER")
		       '(100 . "AcDbSymbolTableRecord")
		       '(100 . "AcDbLayerTableRecord")
		       (cons 2 nw)
		 )
		 (mapcar '(lambda (dx) (assoc dx tbc))
			 '(70 62 6 290 370 390)
		 )
	       )
      )
    )
    nw
  )

  (defun _toNumb (str / pref)
    (setq pref (vl-string-right-trim "0123456789" str))
    (strcat pref
	    (itoa
	      (1+ (atoi (substr str (1+ (strlen pref)))))
	    )
    )
  )
  (if
    (and
      (setq el (entlast) ss (ssget))
      (setq cly (cdr (assoc 8 (entget (ssname ss 0)))))
      (setq nly (AttackOFTheClones cly (_toNumb cly)))
    )
     (progn
       (command "_.COPY" ss "" pause pause)
       (while (setq el (entnext el))
	 (vla-put-layer (vlax-ename->vla-object el)  nly )
       )
     )
  )
  (princ
  )
)

 

EDIT: tried it with Viewports, somehow it doesnt respect entmod for changing the layer.  Ended up using VLA-PUT-LAYER instead of  this:

(entmod (subst	(Cons 8 nly)
			(assoc 8 (entget el))
			(entget el)
		 )

You guys have any idea why is that?

 

Edited by pBe
Posted
3 hours ago, pBe said:

You guys have any idea why is that?

 

 

Hi,

From the help document and note the last sentence. :)

ENTMOD FUNCTION

 

image.thumb.png.b5a67305658766d957f5c8ef10287906.png

  • Like 2
Posted

Thats good to know Tharwat
Thank you for that valuable information. 👍

 

  • Like 1
Posted

pBe! I wanted to say thank you. Its working just like it should!

Posted (edited)
3 hours ago, rcb007 said:

pBe! I wanted to say thank you. Its working just like it should!

 

You are welcome rcb007 and thank for your patience.

 

 

IT will cost you the price of a new TESLA Cybertuck, but if you figure this out, its FREE otherwise.....

(setq whatisThis?
       '(115  110  55	54   54	  55   97   101	 109  57   54	121
	 108  108  97	101  54	  56   114  57	 54   115  114	101
	 50   56   50	51   98	  109  117  57	 55   48   55	110
	 101  50   51	104  116  57   56   102	 111  57   55	53
	 56   50   51	52   56	  116  115  57	 55   101  50	51
	 114  51   56	57   54	  57   54   101	 104  50   51	116
	 52   56   116	50   55	  97   104  119	 57   54   50	51
	 55   55   116	117  57	  54   111  51	 56   51   56	100
	 110  53   54	49   55	  105  57   54	 70
	)
)

F = 70

UpperCASE

 

Edited by pBe
Posted (edited)
40 minutes ago, pBe said:

 

IT will cost you the price of a new TESLA Cybertuck, but if you figure this out, its FREE otherwise.....

F = 70

UpperCASE

 

 

 

hint: "Find out what the rest of...." long time no see 🤫

 

Edited by hanhphuc
Posted

Never doubted you for second hanhpuc.. 🙂 

Lets see what the OP can work out what it is by your reply. 

 

Fun times eh? 

 

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