Jump to content

Recommended Posts

Posted

hey again guys

 

I'm looking for a little lisp that i can expand on to suit our standard layers

 

I'm looking for a lisp that can setup new layers in a drawing - names - colors and linetypes

 

But if a layer name already exists dont ask the user to redefine

 

Is there an existing lisp that someones knows about?

 

Cheers

Posted

Why dont you just setup a template file with all your standard layers created in it?

Posted

I have already set up one - but everyone wants a simple button to import layers.

 

 

Thanks though

\:)

Posted

and i would rather set it up using a lisp for adding layers than bringing in a template

 

Any ideas?

 

Whats the function in a lisp to bring in a layer set its color and linetype

 

and i'll write the rest and post it back for you to pick it to pieces and advise me on all the errors i make

 

ha

 

Cheers

Posted

It would be easier to drag the layers from your template using Design Center, but this should get you started...

(command "-layer" "m" "[color=Red]layername[color=Black]" "c" "[color=Red]color[color=Black]" "" "l" "[color=Red]linetype[color=Black]" "" "")

[/color]

[/color][/color][/color][/color][/color]

Posted

i was thinking of using something like this to import layers and set them up - but doing this for each layer would be alot of work for the pc - is there a easier way of doing it or should i just resolve to creating a lisp to import a template file and delete it thus setting up all layers etc

 

 

any ideas?

 

Cheers

 

(if(not(tblsearch "LTYPE" "EX_GAS"))
     (command "-linetype" "_l" "EX_GAS" "services" "")
    ); end if
 
 (if(not(tblsearch "LAYER" "EXSRV_GAS"))
    (command "-layer" "new" "EXSRV_GAS" "Color" 251 "EXSRV_GAS" "LTYPE" "EX_GAS" "EXSRV_GAS" "")
    );end if

Posted

Look at this function:

 

(defun CreateLayers(layLst / layCol nLay)
 (vl-load-com)
 (setq layCol(vla-get-Layers
	(vla-get-ActiveDocument
	  (vlax-get-Acad-object))))
 (foreach itm layLst
   (if
     (not(vl-catch-all-error-p
(setq nLay(vl-catch-all-apply 'vla-Add
	    (list layCol(car itm))))))
     (vla-put-Color nLay(cadr itm))
     ); end if
   ); end foreach
 (princ)
 ); end of CreateLayers

 

And try it with list '(("LayerName1" Color)...):

 

(CreateLayers '(("MyLayer1" 1)("MyLayer2" 2)("MyLayer3" 3)))

Posted

Thankyou once again asmi - i will look at this method

 

Cheers mate

  • 2 years later...
Posted

So how can the routine load linetypes? i see from the code you can specify the layer, colour, and line type name...does it pull from the acadiso.lin? or acad.lin? can you specify where it loads from?

 

Just starting to learn lisps ...

 

thanks!

Posted
So how can the routine load linetypes? i see from the code you can specify the layer, colour, and line type name...does it pull from the acadiso.lin? or acad.lin? can you specify where it loads from?

 

Just starting to learn lisps ...

 

thanks!

 

Check MEASUREINIT system variable

See Help

 

~'J'~

Posted

i found as long as the lin file is in the working directory it pulls from that.

I dont want to change the MEASUREINIT system variable.

 

Im more concerned (now) with figuring out the spacing of the coding for the layers. I've been having a rough go so far. It was working then it stopped and i've been getting syntax errors. Im trying to play with the (mapcar 'MkLay .... part of the lisp.

 

instead of listing in columns can i run a series of MkLay sections?

 

I started with: (there are spaces they just didnt carry through to this post....):

(defun c:DoLayers ( / )

(vl-load-com)

 

(mapcar 'MkLay

 

'( "CEN" "DIMS" "HAT" "HID" "LOGO" "OBJ" "PAPER" "PHAN" "TITLE" "TXT") ; Name [str]

'( 6 1 3 4 176 2 5 6 176 7 ) ; Colours [int]

'("CENTER" nil nil "HIDDEN" nil nil "PHANTOM" "PHANTOM" nil nil ) ; LineType [str]

'( "018" "018" "018" "015" "009" "040" nil "018" nil nil ) ; LineWeight [str] 0.18 = "018"

'( T T T T T T nil T T T )) ; Plottable (T or nil)

....but am trying to make it simpler to add a whole bunch of layers and colours. I only have notepad to edit ...any suggestions?

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