Author Topic: Change object layer color in Macro  (Read 4268 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Change object layer color in Macro
« on: November 15, 2004, 10:29:39 AM »
For what I am trying to do, this macro is working very well but I would like to make the object that is being copyclipped and pasted the color green while every thing else on defpoints is blue.

I am going to say no, but is it possible to make this happen with a simple macro such as this?

Thank you

Mark


Code: [Select]

^C^Ccopyclip;\;(setvar "tilemode" 1);-layer;s;defpoints;;pasteblock;s;192;\(setvar 'clayer "0");

MikePerry

  • Guest
Change object layer color in Macro
« Reply #1 on: November 15, 2004, 04:18:57 PM »
Hi

Not using PasteBlock as you would then need to modify Objects within a Block (would need something like LISP or VBA for that).

Something like the following would work -

Code: [Select]
^C^C_.CopyClip;\;(setvar "TileMode" 1);_.-Layer;_Make;Defpoints;;_.PasteClip;_S;192;\_.Change;_L;;_P;_Color;3;_Layer;Defpoints;;(setvar "CLayer" "0")

Have a good one, Mike

ML

  • Guest
Change object layer color in Macro
« Reply #2 on: November 15, 2004, 05:11:54 PM »
Mike,
That is great! Perhaps I should have mentioned that I use the pasteblock command so that the mview goes into model as a block reference as opposed to a viewport.

So, I think what needs to happen is the viewport needs to possibly get coppied first, color changed then pasteclipped into model.

Prefeerably, I would like to have the viewport somehow converted to a polyline once it hits model

Any suggestions?

Thanks again

Mark

MikePerry

  • Guest
Change object layer color in Macro
« Reply #3 on: November 15, 2004, 06:25:55 PM »
Hi

Ok! am I right in thinking this is related to the following threads -

Copying, Exploding or Changing Viewports in Model Space

Macro Help

If yes, I honestly think you would be best served by something like the following LISP Routine to accomplish a rectangular boundary in Modelspace (TileMode = 1) that represents a Paperspace (TileMode = 0) Floating Viewport -

viewport limits routine help

Have a good one, Mike

ML

  • Guest
Change object layer color in Macro
« Reply #4 on: November 15, 2004, 07:37:00 PM »
Hey Mike

Yes, it is related, I am just re visiting it

The person who did  that routine did a real good job but it is just shy of how I need it to work.

Unfortunately I am not real good at LISP so I really can't tweak it to my needs.

If you can, I would be glad to help you out if I can? I have some nice little VBA Modules

Thanks again

Mark

MikePerry

  • Guest
Change object layer color in Macro
« Reply #5 on: November 16, 2004, 05:34:46 AM »
Hi Mark

What's it "shy" of? (Apart from not dealing with Polygonal Floating Viewports).

My LISP is a very long-way from good, but I will happily help out if I'm able to....

Might be worth getting this thread moved to the AutoLISP (Vanilla / Visual) Forum - there's LISP Jedi people to be found there that I'm sure could easily help you out.

As a side note (sorry I was meant to mention this earlier) - I would personally recommend that you don't place anything on Layer "Defpoints" (Obviously apart from what AutoCAD automatically places there).

Cheers, Mike

ML

  • Guest
Change object layer color in Macro
« Reply #6 on: November 16, 2004, 08:57:56 AM »
Mike

Did you get this error (see below), do you know what is causing it?

The routine loaded successfully but as soon as I shut the load applications box, it is no longer available


Command: appload

Vport Limits.lsp successfully loaded.


Command: ; error: malformed list on input

MikePerry

  • Guest
Change object layer color in Macro
« Reply #7 on: November 16, 2004, 09:52:51 AM »
Hi

No, worked fine when I tried it....

I Copied, Pasted & Saved the routine from the following post -

viewport limits routine help

Have a good one, Mike

ML

  • Guest
Change object layer color in Macro
« Reply #8 on: November 16, 2004, 09:49:47 PM »
Hey Mike,

This lisp routines works fine. It is a real sweet routine. The only thing that I would like is for it to switch to Model (like my macro does) and prompt you for an insertion point, which my macro also does.

Do you think it is possible to make tha happen?

Thanks

Mark

MikePerry

  • Guest
Change object layer color in Macro
« Reply #9 on: November 17, 2004, 07:03:27 AM »
Quote from: ML
The only thing that I would like is for it to switch to Model (like my macro does) and prompt you for an insertion point, which my macro also does.

Do you think it is possible to make tha happen?

Hi Mark

Can I please ask why?

Only ask as I would've thought the automatic placement achieved from the routine would be the most favourable result.

As I've been told on many occasions, anything is possible.... I will take a look, if I can't I'm sure there's at least one person within The Swamp that can.

Cheers, Mike

MikePerry

  • Guest
Change object layer color in Macro
« Reply #10 on: November 17, 2004, 10:14:41 AM »
Quote from: ML
Do you think it is possible to make tha happen?

Hi Mark

The below should meet your requirements, it's definitely not pretty but....

Code: [Select]
;http://theswamp.org/phpBB2/viewtopic.php?t=2224
;Swamp Additions by MikePerry 2004.11.17 to meet "ML's" requirements
;Tip1687: VPLIM.LSP  Pspace Limits in Mspace (c)2001, Murray Clack
;VPLIM.lsp draws the limits of a Paperspace Viewport Boundary in MODELSPACE
;VP - Get ViewPort object
;HT - Get Outside HeighT of Viewport
;WD - Get Oustide WiDth of Viewport
;VN - Get Viewport Number
;CTR - Get CenTeR of Viewport
;CTRX - Caluculate X of Viewport CenTeR
;CTRY - Caluculate Y of Viewport CenTeR
;VS - Get View Size of viewport
;XP - Calculate XP factor of viewport
;IW - Calculate Width of viewport
;BL - Calculate Bottom Left corner of viewport
;BR - Calculate Bottom Right corner of viewport
;TR - Calculate Top Right corner of viewport
;TL - Calculate Top Left corner of viewport
;PW - Save PlineWid
;OS - Save OSmode
;Current_Layer - Swamp Add Save Current Layer
;start function and define variables

(defun C:VPL (/     VP    HT   WD  VN CTR CTRX   CTRY
     VS     XP    IW   BL  BR TR TL     PW
     OS     Current_Layer
    );Swamp Add - Current_Layer
  (setvar "cmdecho" 0);turn off command echoing
  (command ".pspace");enter pspace
  (setq VP ;select viewport boundary
(entget
  (car
    (entsel
      "\nSelect Viewport to Draw Boundary
             in "
    );_ end of entsel
  );_ end of car
);_ end of entget
  );_ end of setq
  (setq HT (cdr (assoc 41 VP)));Get Viewport height with
  (setq WD (cdr (assoc 40 VP)));Get Viewport width with
  (setq VN (cdr (assoc 69 VP)));Get Viewport Number
  (command ".mspace");enter mspace
  (setvar "cvport" VN);set correct viewport
  (command ".ucs" "v");set UCS to View
  (setq CTR (getvar "viewctr"));Get VIEWCTR store as CTR
  (setq CTRX (car CTR));Get X of CTR
  (setq CTRY (cadr CTR));Get Y of CTR
  (setq VS (getvar "viewsize"));Get inside Viewport height
  (setq XP (/ HT VS));Get XP Factor with HeighT / View Size
  (setq IW (* (/ VS HT) WD));Get inside width of Viewport by
  (setq BL (list (- CTRX (/ IW 2)) (- CTRY (/ VS 2))));Find four corners of Viewport
  (setq BR (list (+ CTRX (/ IW 2)) (- CTRY (/ VS 2))))
  (setq TR (list (+ CTRX (/ IW 2)) (+ CTRY (/ VS 2))))
  (setq TL (list (- CTRX (/ IW 2)) (+ CTRY (/ VS 2))))
  (setq PW (getvar "plinewid"));Save current pline width
  (setvar "plinewid" 0);Set Pline width to zero
  (setq OS (getvar "osmode"));Save current osmode
  ;Swamp Add - Save Current Layer
  (setq Current_Layer (getvar "CLayer"))
  ;Swamp Add - Ensure Layer Defpoints exists and set current
  (command "_.-Layer" "_M" "Defpoints" "")
  (command ".pline" BL BR TR TL "c");Draw pline inside border
  (setvar "plinewid" PW);Restore pline width back
  ;Swamp Add - Restore Saved Current Layer
  (setvar "CLayer" Current_Layer)
  (command ".ucs" "p");Restore UCS back
  (setvar "osmode" OS);Restore osmode
  (command ".pspace");Go Back To Papserspace
  ;Swamp Add - Switch to Modelspace
  (setvar "TileMode" 1)
  ;Swamp Add - Force PLine on Layer Defpoints to Colour Green (3)
  (command "_.Change" "_L" "" "_P" "_Color" "3" "")
  ;Swamp Add - Cut PLine on Layer Defpoints to the Clipboard
  (command "_.CutClip" "_L" "")
  ;Swamp Add - Paste PLine on Layer Defpoints allowing User to place as required
  (Command "_.PasteClip")
  (princ);Clean up command prompt
);The End!


Have a good one, Mike