loudy000 Posted August 21, 2019 Posted August 21, 2019 hey guys, i have a little knowledge on c#, basically i want to do something like foreach(Polyline pl in selected polylines) { ///do something }; but i dont have any idea how to do it using lisp. this is the command i want to run for each polyline (command "_MAPCreateFeatureFromGeometry" "yes" "landuse" "") ) thanks in advance. Quote
Tharwat Posted August 21, 2019 Posted August 21, 2019 Hi, That is an iteration process and here is one way as in the following : (if (setq ss (ssget "_:L" '((0 . "LWPOLYLINE")))) (repeat (setq no (sslength ss)) (setq sn (ssname ss (setq no (1- no)))) ;; do something here for the polyline entity. 'sn' = 'pl' as into your example ) ) NOTE: How come that command call does not have the entity itself to run with ? the variable 'pl' as into your example ! Quote
loudy000 Posted August 22, 2019 Author Posted August 22, 2019 Hi @Tharwat sorry, here's the full command i want to repeat for each selected polyline (Defun c:pll () (while (setq s (ssget)) (sssetfirst nil s) (command "_MAPCreateFeatureFromGeometry" "yes" "Landuse" """") )) Thank you i dont know how to incorporate it in your code, i tried pasting it under don something but it's not working. Again Thank you. Quote
Tharwat Posted August 22, 2019 Posted August 22, 2019 Does this command "_MAPCreateFeatureFromGeometry" require the polylines to be selected ( highlighted ) in prior ? Quote
loudy000 Posted August 22, 2019 Author Posted August 22, 2019 yes please, so the work flow is 1. Select Polylines 2. then run that command for each selected polyline Thanks for your help Quote
Tharwat Posted August 22, 2019 Posted August 22, 2019 But you did not include the variable 'pl' within the posted codes into your first post ? (command "_MAPCreateFeatureFromGeometry" "yes" "landuse" "") Quote
loudy000 Posted August 22, 2019 Author Posted August 22, 2019 oh sorry you have to run that command first then apply to each polyline, currently working with single polyline so command, then select polylines Quote
Tharwat Posted August 22, 2019 Posted August 22, 2019 Something like this? (defun c:Test ( / ss) (if (setq ss (ssget "_:L" '((0 . "*POLYLINE")))) (command "_MAPCreateFeatureFromGeometry" ss "" "yes" "landuse" "") ) (princ) ) Quote
loudy000 Posted August 23, 2019 Author Posted August 23, 2019 Thanks @Tharwat however i still cant get it to work, sorry it's kind of difficult to explain what the command does.. Please see attached. so thats basically i want to run on multiple polylines as separate (fill) Thanks again. Quote
Tharwat Posted August 23, 2019 Posted August 23, 2019 Hopefully the following would work and you may need to use the system variable filedia to disable the prompt of the Dialog box. (defun c:Test ( / ss no) (if (setq ss (ssget "_:L" '((0 . "*POLYLINE")))) (repeat (setq no (sslength ss)) (command "_MAPCreateFeatureFromGeometry" "landuse" "" (ssname ss (setq no (1- no))) "" "yes") ) ) (princ) ) Quote
loudy000 Posted August 23, 2019 Author Posted August 23, 2019 Thanks again, appreciate your help however it only works with single poly line. I modify it a bit because above code is not working. cheers (defun c:Test ( / ss no) (if (setq ss (ssget "_:L" '((0 . "*POLYLINE")))) (repeat (setq no (sslength ss)) (command "MAPCreateFeatureFromGeometry" "Landuse MP" (ssname ss (setq no (1- no))) "" "yes") ) ) (princ) ) Quote
Tharwat Posted August 23, 2019 Posted August 23, 2019 Can you post the working C# codes so I can convert them into lisp if they are not that complicated? You did not show the command line if the codes throw any error to allow me to know how things going on with the codes.! Quote
BIGAL Posted August 24, 2019 Posted August 24, 2019 Like Tharwat are you just hatching multiple plines, doing an inside parallel pline. or other options. What I am suggesting is the options may all be done already in lisp. Ssget has multiple select filters that you can use and can be multiple of, such as layer, all or all in a particular space model / layout. 1 Quote
loudy000 Posted August 24, 2019 Author Posted August 24, 2019 (edited) 10 hours ago, Tharwat said: Can you post the working C# codes so I can convert them into lisp if they are not that complicated? You did not show the command line if the codes throw any error to allow me to know how things going on with the codes.! Hi @Tharwat technically there's no actual c# code it's just an example of what im after, i think it's close just need to create separate hatch for each poly line. So say select 3 or 4..poly lines and create hatch for each. Edited August 24, 2019 by loudy000 update attachement Quote
loudy000 Posted August 24, 2019 Author Posted August 24, 2019 5 hours ago, BIGAL said: Like Tharwat are you just hatching multiple plines, doing an inside parallel pline. or other options. What I am suggesting is the options may all be done already in lisp. Ssget has multiple select filters that you can use and can be multiple of, such as layer, all or all in a particular space model / layout. Thanks @BIGAL Quote
BIGAL Posted August 25, 2019 Posted August 25, 2019 This is real quick and not very detailed and would normally have a front end to choose hatch pattern and scale etc but gives a result. You need to provide more detail. Do you want them different colors etc. (defun c:qkhatch ( / ss x) (if (setq ss (ssget (list (cons 0 "lwpolyline")))) (progn (setvar 'hpname "Ansi31") (setvar 'hpscale 2.0) (repeat (setq x (sslength ss)) (command "-hatch" "S" (ssname ss (setq x (1- x))) "" "p" "" "" "" "") ) ) ) ) (c:qkhatch) Quote
Roy_043 Posted August 25, 2019 Posted August 25, 2019 There is a variable, HPSEPARATE, that governs if the _Hatch commands creates separate hatches or not. So what BIGAL is doing can be done without Lisp code. Quote
loudy000 Posted August 25, 2019 Author Posted August 25, 2019 Thanks @BIGAL for that it's not actually hatch command that i want to run for each poly line. It's the code above (defun c:Test ( / ss) (if (setq ss (ssget "_:L" '((0 . "*POLYLINE")))) (command "_MAPCreateFeatureFromGeometry" ss "" "yes" "landuse" "") ) (princ) ) so i tried to adopt it and i thought it should be similar, just different command, but for some reason it's not working. Thanks again for your help guys. (defun c:qkhatch ( / ss x) (if (setq ss (ssget (list (cons 0 "lwpolyline")))) (progn (repeat (setq x (sslength ss)) (command "_MAPCreateFeatureFromGeometry" "Landuse MP" (ssname ss (setq x (1- x))) "yes" "" "" "") ) ) ) ) (c:qkhatch) Quote
BIGAL Posted August 25, 2019 Posted August 25, 2019 In your video the map select asks for you to pick the pline that’s where the ssname needs to go. You may need to select the object before running the command. Try it above, on IPad so no test. Quote
Recommended Posts
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.