• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

problem change layer

carmelo81

Guest
Bye to all,
I use the lisp code below (not mine) to make a double offset, only that in the end the new lines are automatically moved to layer 0 and I don't understand why.
Can you help me solve this?
Thank you very much
Code:
(refun c:k (/ ent dist obj krd)
(setq dist (* 0.5 (getdist "\nenter offset distance: ")))
(while (not graft)
(if (eq (setq ent (car))
nil
)
(princ "\nthat was not a line. please select again: ")
)
)
(initget (+ 1 2 4 64))

(setq obj (vlax-ename->vla-object ent))
(fla-offset obj dist)
(fla-offset obj (* dist -1))

(vla-erase obj)

(princ)
)
 
moving on layer 0 is not performed by this routine, the vla-offset command uses the layer of the source line.
 
Right.
There is not only one instruction that changes the current layer or new entities.
and tried the list the offset happens correctly.

check if you set the offset command with the current option instead of source
 
as rightly rpor66 writes, there is no layer shift, and on autocad works perfectly, I can think that depends on the software you use, you could try to use this modified code that forces the allocation of the layer to the two lines created, taking it from the selected one.
 

Attachments

thanks raga for the answers. .
check if you set the offset command with the current option instead of source
in fact the command works correctly but it changes layer, bo... I confirm that the option is in source.
as rightly rpor66 writes, there is no layer shift, and on autocad works perfectly, I can think that depends on the software you use, you could try to use this modified code that forces the allocation of the layer to the two lines created, taking it from the selected one.
Thank you very much, I will eventually use your code because perfectly working.
 
as rightly rpor66 writes, there is no layer shift, and on autocad works perfectly, I can think that depends on the software you use, you could try to use this modified code that forces the allocation of the layer to the two lines created, taking it from the selected one.
scusami joblayer ho ancora due domande sul tuo codice:1: the cycle while allows me to do so many offsets without closing the command? because if so, it doesn't work.2: how do I store the variable value dist so you have the same value when I call the command?

Thanks again
 
scusami joblayer ho ancora due domande sul tuo codice:1: the cycle while allows me to do so many offsets without closing the command? because if so, it doesn't work.2: how do I store the variable value dist so you have the same value when I call the command?

Thanks again
the while cycle in question, does not allow you to do so many offsets, but aims to continue to ask you to select a line, until you select in nothing. a solution to what you need can be this modification, which repeats the command for 100 times, being able to select repetition lines, without changing the dist variable, and pressing "esc" when you want to finish, an error message will be shown, which is not very clean, but at that point you have already achieved the purpose.
 

Attachments

Well, it's always something though a little rudimentary. I'll use it for more, thank you!

instead for the second question, is there a specific way to solve?
Thanks again
 
I try to answer your second question, someone will correct me if I write nonsense, when you run a lisp command the variables in it are active until the end of the command, after which they are lost, to track your "dist" variable you need to save it somewhere. autocad uses its numerous system variables for its references and references of its commands, throughout the drawing session, but a lisp command does not have its own space outside of it, or at least I did not find it. I remember reading that there were 4 system variables available to the user, but I couldn't find them (if anyone knows anything more is well accepted), so I exploited the variable used by offset to recover your "dist" variable, but it could be upset if between two lisp commands in question was used offset with different distance. Another alternative would be to save the variable in a text file in a pc location, and recover it in need, but you would go dirty around, I don't know if it is worth it.
 

Attachments

the variables in lisp arise at the opening of a dwg, they die at the closing, always that does not change the variable lispinit.
There are 5 double-type variables, userr1÷5, and 5 integer type, useri1÷5, values stored in the dwg.
nothing prohibits memorizing the value of the variable in an external file, like myoffset.ini, managed by the routine in lisp.
 
Hi.
users1, users2, users3, users4, and users5 are variables available to the user, on the web you easily find details about use.
You can use them easily. I need more, and I don't have enough, for example for the parameters of how to launch a render.
I have devised heredi a simple system even if rough, but that has no contraindications. in lisp, from menu, I create varable of physical "environment", simply creating layers that do not contain objects but are reports.
example.... type of sky "storm... sunset... etc"
and also the quota for underwater rendering.. the exact quota of the observation point. It's rough but it works and has no limits.
 
thanks to both "rpor66" and "gio_s". I remembered similar names, but I couldn't find them, when I type "_setvar" to the command line to see the list of all variables, these 5 users are not visible, but in any case now if I call them directly with his name I can manage them easily.
Thanks again.
 
Well, it's always something though a little rudimentary. I'll use it for more, thank you!

instead for the second question, is there a specific way to solve?
Thanks again
with the help received I can attach the last update of your code.
 

Attachments

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.

Back
Top