Jump to content

Variable Not Passing Contents?


treaves04

Recommended Posts

In the code below for some reason the constlist2 is not passing it's contents to the layer command. It is setting the variable correctly when I check it, so I am not sure where the issue lies. If you would like to test the code first type in the command line (setq CurLevel 2). This will establish what level you are on and change the 1 in the layer names to a 2.

 

(setq constlist "*1-WALL-*,*1-PLUM-FX-*,*1-STRT-*")
(setq conaddlay "*-CLAD-*")

(Defun constmode (/ n) 
	(setq constlist2 (vl-string-translate "1" (itoa CurLevel) constlist))
	(command "-LAYER" "T" constlist2 "T" conaddlay "ON" constlist2 "ON" conaddlay "U" constlist2 "U" conaddlay "")
)

Link to comment
Share on other sites

If I type in or write out the list that way it works fine. The * are not in the name but are wildcards, so that if there is anything in front or behind it will still catch it.

Link to comment
Share on other sites

Why don't you make list of real layer names that are in DWG, based on * filters using (wcmatch) function and pass that list to layer command...

Link to comment
Share on other sites

I want to try and avoid writing the same thing 30 + times like I am doing now. Which is a pain in the but when you want to and a new layer type. I have a bunch of commands that I am calling that would utilize this function. Making things a lot simpler to edit.

 

Our drawings consist of a base file which contains anything that does not change from elevation to elevation in full 3d (we have multiple fronts for each house). The fronts are xrefs along with any options that we want to add that may be in the base portion of the house. The program I have put together (with a lot of help from you wonder people) filters through and turns on the right stuff based on the command you call. If I call command FRELE it prompts for which elevation letter I want to see. Say I select B. Now it will display only the base house and anything pertaining to the B elevation when a I call my mode commands. So if I call L1E it will take me to my first floor electrical. Or say I want to go to my construction drawing on the 2nd floor. Type L2 and it will make all the right stuff visible and turn everything else off.

 

Hope that helps shed a little more light on what I am doing.

Link to comment
Share on other sites

Nothing immediately jumps out as wrong when looking over your posted code - could you possibly post the command-line output when running the program to demonstrate the problem you are receiving?

Link to comment
Share on other sites

Below is the command where I call the constmode function. When I call this command it returns nil.

 

(Defun C:L1 ()  (L1))
(Defun L1 () 	(setq CurLevel 1)
	(alllayoff)
	(constmode)
	(filterelev)
	(command-s "elevation" FL1)
	(command-s "Osnapz" "1")
		(AecSetLayerKeyOverride "LEVEL" "1")
	(command-s "-AECDisplayConfigSetCurrent" "1")
	(mainxref)
	(regenerate)
)

 

But if I substitute the following code in place of the constmode function everything works seamlessly.

 

(command-s "-LAYER" "T" "*1-WALL-*,*1-PLUM-FX-*,*1-STRT-*,*-CLAD-*" "ON" "*1-WALL-*,*1-PLUM-FX-*,*1-STRT-*,*-CLAD-*" "U" "*1-WALL-*,*1-PLUM-FX-*,*1-STRT-*,*-CLAD-*" "" "")

Link to comment
Share on other sites

But does function (constmode) performs what should - displaying of layer states changes as desired?

 

If that's so, then only thing you should do to avoid nil prompt is to add (princ) at the end of (constmode) function...

 

If that isn't so, perhaps you may consider putting those setqs before (constmode) inside (constmode), right?

Edited by marko_ribar
Link to comment
Share on other sites

I have tried that also and that does not fix it. I have all of my variables that I may use in a field or in some other way initializing at start up so that all of my tables can read the data correctly.

Link to comment
Share on other sites

Well one idea that jumps out to me is to change some call-names

do you do call that function like this?

L1 (L1)

 

?

 

Seems a bit odd

Link to comment
Share on other sites

The reason for that is so that other programs can call the commands. We have a program that auto updates our marketing material that calls the commands and then cross selects a poly line around the house and prints to png. I am not having any issues with that portion it is just when I tried to rewrite the one line and make it a function to make it easier to edit. So I wont have to edit it in 30 places. If I change the code back to where I am listing out each layer all is well. I just can't figure out why the layer command is not taking the contents of the variable, but it is instead putting in the name of the variable. Which I would understand if I placed it in quotations, but it is not in quotes.

Link to comment
Share on other sites

Why don't you just change the constmode to be that layer command, or, alternatively you could add the following code to effectively do the same

 

(if (= nil constmode)(command-s "-LAYER" "T" "*1-WALL-*,*1-PLUM-FX-*,*1-STRT-*,*-CLAD-*" "ON" "*1-WALL-*,*1-PLUM-FX-*,*1-STRT-*,*-CLAD-*" "U" "*1-WALL-*,*1-PLUM-FX-*,*1-STRT-*,*-CLAD-*" "" ""))

 

If I read that properly that constmode is returning nil. Hard to say without further testing. A question, where is the usage of strcat if you are concatenating your layer names within a variable set?

Link to comment
Share on other sites

That is probably what I will have to do, but the reason why I didn't want to is that the number in the front of the layer name represents the level and I wanted to write one constmode instead of having to have one for each level (0,1,2,3,4). Does that make sense?

Link to comment
Share on other sites

So you're wanting the constlist2 variable to be your new layer name, where if there is a "1" within that layer name, it will be replaced with the integer representation of "CurLevel"?

Take a look at this routine from BB, that concatenates "_ISO" onto the current layer's name and sets that layer_ISO current. If it does not exist already the routine creates it then sets it current.

Tell me the differences in what you're needing and what this routine does so that we can modify it correctly as per your needs.

HTH, I went this route because I have client work in front of me that will take my time for the next short while, and this allows us progress nonetheless towards achieving your goal

Link to comment
Share on other sites

Yes that is correct. Constlist2 will be the new layer names. So if the CurLevel is 2 the constlist2 would be equal to "*2-WALL-*,*2-PLUM-FX-*,*2-STRT-*". The way I have the code written now does this but when I place the variable where I need it in the layer command it does not pass it's contents. Shouldn't it take the contents of the variable?

Link to comment
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
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...