Jump to content
Jef!

MD_ (viewbase) layers - reactor @ plot

Recommended Posts

Jef!

Hi everyone!

 

I just want to start by thanking you all, as most of the times I have an issue this forum is a great resource in which I find many answers without having to create a thread

 

Since we use Acad 2014, some of my coworkers have started using viewbase style views. Since we have standards regarding lineweights, I've tried to find in vain a way to set the lineweight default values for the viewbase layers (MD_Annotation, MD_Hatching...) when CAD create them. Since i couldn't find any way to give them default values upon creation, my only option was to pre created on our templates all the layers generated by viewbase. The thing is that when someone purge a drawing prior to create the first viewbase, (which is 95% of the cases - designers make the design/3d model, purge, then the draftsman takes over the project to make the fab plans) the MD_ layers get deleted, and when they are generated again all the lineweights don't match our standards.

 

From my perspective, I now have 2 options.

1- Beat the hell out of the designers whenever they purge the layers (which is not very nice..) :D

2- find a workaround (which I did, but I would need some help to achieve my goal since I'm not really acquainted with reactors)

 

basically what I need is a reactor (in acaddoc.lsp i'd guess?) doing that:

 


reactor@plot: verify if layers (MD_Annotation, MD_Hatching, MD_Hidden, MD_Visible) exist

if not: resume plot 

if they do exist: check lineweight setting to ensure they match our standards 
(MD_visible = default, MD_hatching = .05mm, MD_hidden = .13mm, annotation=default)
if true: plot
if not: change values then plot

 

If the MD_ layers do exist, i'm not sure if I should bother looking at their lineweight value to compare them with our standard, to change their value if they dont, or if I should directly set their lineweight value if the layers exist.

 

Thanks in advance for your help

Cheers,

Jef!

Share this post


Link to post
Share on other sites
rkent

Use the low tech way and create a very small line in the template on each layer. Draw those on top of existing lines, say the title block border.

Share this post


Link to post
Share on other sites
jdiala

I'm not sure if you can use a reactor on plot since command reactor will initiate after the command is executed (I maybe wrong). Probably undefine the plot command and replace it with a routine or just use a lisp with plot command.

 

(defun C:vplot (/ laylist lwlist laytbl)
(setq laylist (list "MD_Annotation" "MD_Hatching" "MD_Hidden" "MD_Visible")
     lwlist  (list -3 5 13 -3)
     laytbl  (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
)

(mapcar 
 (function  
   (lambda (a b) 
     (if 
       (tblsearch "LAYER" a)
       (vla-put-Lineweight (vla-item laytbl a ) b) 
       (princ (strcat "\nLayer " (strcase a) " does not exist")) )))
     laylist
     lwlist
)
(princ)
(initdia)
(command "_.plot")
)

Share this post


Link to post
Share on other sites
BlackBox
Use the low tech way and create a very small line in the template on each layer. Draw those on top of existing lines, say the title block border.

 

... Back in +/-2006, we used to use points as our default was PDMODE == 1 :rofl:... Then I found Reactors, and ObjectDBX. :geek:

Share this post


Link to post
Share on other sites
Jef!

Good morning, and thanks for the feedback and help!

 

@rkent: I thouht about the adding a line in the titleblock but wanted to keep the posibility of being able to purge these layers whenever they are not in use, mainly because we use a lot of xrefs.

 

I'm not sure if you can use a reactor on plot since command reactor will initiate after the command is executed (I maybe wrong). Probably undefine the plot command and replace it with a routine or just use a lisp with plot command.

Come to think of it, I think that your right and the reactor initiate after the command. Redefining the command is the way to go, it work like a charm!

 

I've change 3 tiny things tho, because I had no line return in between the last "MD_xxx does not exist" and the line sent by the plot command, and the last line was a nil. (Ive also added another layer that I wanted to control its lineweight.)

 

CAD was saying:

Layer MD_HATCHING does not exist

Layer MD_HIDDEN does not existEffective plotting area: 35.54 wide by 23.15 high

Effective plotting area: 5.33 wide by 4.14 high

Plotting viewport 2.

Plotting viewport 1.

nil

 

So now it looks like that

(command "undefine" "plot")
(defun C:plot (/ laylist lwlist laytbl)
(setq laylist (list "DIM" "MD_Annotation" "MD_Hatching" "MD_Hidden" "MD_Visible")
     lwlist  (list 9 -3 5 13 -3)
     laytbl  (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
)
(mapcar 
 (function  
   (lambda (a b) 
     (if 
       (tblsearch "LAYER" a)
       (vla-put-Lineweight (vla-item laytbl a ) b) 
       (princ (strcat "\nLayer " (strcase a) " does not exist")) )))
     laylist
     lwlist
)
(princ "\n")
(initdia)
(command "_.plot")
(princ)
)

 

and CAD says:

Command: PLOT

Layer MD_HATCHING does not exist

Layer MD_HIDDEN does not exist

Effective plotting area: 35.54 wide by 23.15 high

Effective plotting area: 5.33 wide by 4.14 high

Plotting viewport 2.

Plotting viewport 1.

 

thank you, jdiala! Much appreciated!

Share this post


Link to post
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.   Paste as plain text instead

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