Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

combine code

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
200 Views, 8 Replies

combine code

I have test both parts of this code separately and I am now trying to combine them.
I either get a malformed list or to many arguments or to few arguments
could someone show me what I did wrong.
does the "or" need to be part of (if (and (or....then the code
thanks for any help

(if (and (< px1 qx1) (= ab 1))
(((command "_.pline" ti2 vert horz "")
(command "text" "j" "mc" htxt ht "0" slopet)
(command "text" "j" "mc" vtxt ht "0" t3sl)
)
)
(((command "_.pline" ti3 vert2 horz2 "")
(command "text" "j" "mc" htxt4 ht "0" slopet)
(command "text" "j" "mc" vtxt4 ht "0" t3sl)
)
)
(or
(if (and (> px1 qx1) (= ab 1))
(((command "_.pline" ti2 vert horz1 "")
(command "text" "j" "mc" htxt2 ht "0" slopet)
(command "text" "j" "mc" vtxt2 ht "0" t3sl)
)
)
(((command "_.pline" ti3 vert2 horz2 "")
(command "text" "j" "mc" htxt4 ht "0" slopet)
(command "text" "j" "mc" vtxt3 ht "0" t3sl)
)
) ;Writes slope to dwg (1)
)
)
)



--
Dave C. Johnson
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

I depends of what do you want to do. I think that the best way to get som
help, is to explain with your own words, what do you want your code to do,
something that's called pseudocode.


"djohnson" a écrit dans le message de news:
6109843@discussion.autodesk.com...
I have test both parts of this code separately and I am now trying to
combine them.
I either get a malformed list or to many arguments or to few arguments
could someone show me what I did wrong.
does the "or" need to be part of (if (and (or....then the code
thanks for any help

(if (and (< px1 qx1) (= ab 1))
(((command "_.pline" ti2 vert horz "")
(command "text" "j" "mc" htxt ht "0" slopet)
(command "text" "j" "mc" vtxt ht "0" t3sl)
)
)
(((command "_.pline" ti3 vert2 horz2 "")
(command "text" "j" "mc" htxt4 ht "0" slopet)
(command "text" "j" "mc" vtxt4 ht "0" t3sl)
)
)
(or
(if (and (> px1 qx1) (= ab 1))
(((command "_.pline" ti2 vert horz1 "")
(command "text" "j" "mc" htxt2 ht "0" slopet)
(command "text" "j" "mc" vtxt2 ht "0" t3sl)
)
)
(((command "_.pline" ti3 vert2 horz2 "")
(command "text" "j" "mc" htxt4 ht "0" slopet)
(command "text" "j" "mc" vtxt3 ht "0" t3sl)
)
) ;Writes slope to dwg (1)
)
)
)



--
Dave C. Johnson
Message 3 of 9
Anonymous
in reply to: Anonymous


As far as syntax, you should lay it out like:

-----------

(if (and (< px1 qx1)(= ab 1))

(progn

(command "_.pline" ti2 vert horz "")

(command "text" "j" "mc" htxt ht "0" slopet)

(command "text" "j" "mc" vtxt ht "0" t3sl)

); progn

;; else

(progn

(command "_.pline" ti3 vert2 horz2 "")

(command "text" "j" "mc" htxt4 ht "0" slopet)

(command "text" "j" "mc" vtxt4 ht "0" t3sl)

); progn

); if

;;

(if (and (> px1 qx1)(= ab 1))

(progn

(command "_.pline" ti2 vert horz1 "")

(command "text" "j" "mc" htxt2 ht "0" slopet)

(command "text" "j" "mc" vtxt2 ht "0" t3sl)

); progn

;; else

(progn

(command "_.pline" ti3 vert2 horz2 "")

(command "text" "j" "mc" htxt4 ht "0" slopet)

(command "text" "j" "mc" vtxt3 ht "0" t3sl)

); progn

); if -- Writes slope to dwg [1]



As for the 'logic' .. in above, one or the other

group of code will fire when ab=1 unless px1=qx1.



If you list the 'results' for:

(> px1 qx1)

.. do this

(< px1 qx1)

.. do this

and

(= px1 qx1)

.. do this (if anything),

it may help you determine what the code

needs to look like.

Bob

Message 4 of 9
Anonymous
in reply to: Anonymous

ok...Ill give it a shot
the first part of the statement will draw a symbol and text either above a line or below a line
depending on the users input (= ab 1) above, other than a 1 it will put it below the line. this is
for a line that angles left to right.

the second part does the same thing but for when the line is angled right to left

hopefully that helps a little.
>
> (if (and (< px1 qx1) (= ab 1))
> (((command "_.pline" ti2 vert horz "")
> (command "text" "j" "mc" htxt ht "0" slopet)
> (command "text" "j" "mc" vtxt ht "0" t3sl)
> )
> )
> (((command "_.pline" ti3 vert2 horz2 "")
> (command "text" "j" "mc" htxt4 ht "0" slopet)
> (command "text" "j" "mc" vtxt4 ht "0" t3sl)
> )
> )
> (or
> (if (and (> px1 qx1) (= ab 1))
> (((command "_.pline" ti2 vert horz1 "")
> (command "text" "j" "mc" htxt2 ht "0" slopet)
> (command "text" "j" "mc" vtxt2 ht "0" t3sl)
> )
> )
> (((command "_.pline" ti3 vert2 horz2 "")
> (command "text" "j" "mc" htxt4 ht "0" slopet)
> (command "text" "j" "mc" vtxt3 ht "0" t3sl)
> )
> ) ;Writes slope to dwg (1)
> )
> )
> )
>
>
>


--
Dave C. Johnson
djohnson@wwcengineering.com
WWC Engineering
Sheridan WY.
Windows xp pro
Acad Map 2008
Carlson 2008
Message 5 of 9
Anonymous
in reply to: Anonymous

oh sure...through another function at me. my head is still swimming with what I have so far 🙂

thanks. I will go through it and see what I can do.
guess I was off base with what I was doing (or trying to do)



EC-CAD wrote:
>
> As far as syntax, you should lay it out like:
>
> -----------
>
> (if (and (< px1 qx1)(= ab 1))
>
> (progn
>
> (command "_.pline" ti2 vert horz "")
>
> (command "text" "j" "mc" htxt ht "0" slopet)
>
> (command "text" "j" "mc" vtxt ht "0" t3sl)
>
> ); progn
>
> ;; else
>
> (progn
>
> (command "_.pline" ti3 vert2 horz2 "")
>
> (command "text" "j" "mc" htxt4 ht "0" slopet)
>
> (command "text" "j" "mc" vtxt4 ht "0" t3sl)
>
> ); progn
>
> ); if
>
> ;;
>
> (if (and (> px1 qx1)(= ab 1))
>
> (progn
>
> (command "_.pline" ti2 vert horz1 "")
>
> (command "text" "j" "mc" htxt2 ht "0" slopet)
>
> (command "text" "j" "mc" vtxt2 ht "0" t3sl)
>
> ); progn
>
> ;; else
>
> (progn
>
> (command "_.pline" ti3 vert2 horz2 "")
>
> (command "text" "j" "mc" htxt4 ht "0" slopet)
>
> (command "text" "j" "mc" vtxt3 ht "0" t3sl)
>
> ); progn
>
> ); if -- Writes slope to dwg [1]
>
>
>
> As for the 'logic' .. in above, one or the other
>
> group of code will fire when ab=1 unless px1=qx1.
>
>
>
> If you list the 'results' for:
>
> (> px1 qx1)
>
> .. do this
>
> (< px1 qx1)
>
> .. do this
>
> and
>
> (= px1 qx1)
>
> .. do this (if anything),
>
> it may help you determine what the code
>
> needs to look like.
>
> Bob
>


--
Dave C. Johnson
Message 6 of 9
Anonymous
in reply to: Anonymous


I think that for a better understanding of the
logic and in order to simplify things, your code could look like
this:

 

(if (= ab 1)
  ;;; if the
above/below test is true, run this branch
  (if (< px1
qx1)
    ;;; if this left/right test is true, run
this branch
   
(progn
      ;;; draw pline
here
      ;;; draw text
here
      ;;; draw text here
   
)
    ;;; otherwise, run this
branch
   
(progn
      ;;; draw pline
here
      ;;; draw text
here
      ;;; draw text
here
    )
  )
  ;;;
otherwise, if the above/below test is false, run this branch
 
(if (< px1 qx1)
    ;;; if this left/right test is
true, run this branch
   
(progn
      ;;; draw pline
here
      ;;; draw text
here
      ;;; draw text
here
    )
    ;;;
otherwise, run this branch
   
(progn
      ;;; draw pline
here
      ;;; draw text
here
      ;;; draw text
here
    )
  )
)

 

Of course, you could, chose the left/right
test for the main IF, amd the above/below test for the secondary one.
And there are other posibilities too, but right now, I don't think that the AND
and OR statments are of any help, but rather the oposite.

 

HTH

 

ok...Ill give it a shot
the
first part of the statement will draw a symbol and text either above a line or
below a line
depending on the users input (= ab 1) above, other than a 1 it
will put it below the line. this is
for a line that angles left to
right.

the second part does the same thing but for when the line is
angled right to left

hopefully that helps a little.
>
> (if
(and (< px1 qx1) (= ab 1))
>      (((command
"_.pline" ti2 vert horz
"")
>         (command "text" "j"
"mc" htxt ht "0" slopet)
>        
(command "text" "j" "mc" vtxt ht "0"
t3sl)
>      
)
>      )
>     
(((command "_.pline" ti3 vert2 horz2
"")
>         (command "text" "j"
"mc" htxt4 ht "0"
slopet)
>          
(command "text" "j" "mc" vtxt4 ht "0"
t3sl)
>      
)
>      )
>     
(or
>        (if (and (> px1 qx1) (=
ab 1))
> (((command "_.pline" ti2 vert horz1 "")
>   
(command "text" "j" "mc" htxt2 ht "0" slopet)
>    (command
"text" "j" "mc" vtxt2 ht "0" t3sl)
> )
> )
> (((command
"_.pline" ti3 vert2 horz2 "")
>    (command "text" "j" "mc"
htxt4 ht "0" slopet)
>       (command "text"
"j" "mc" vtxt3 ht "0" t3sl)
> )
> ) ;Writes slope to dwg
(1)
>       
)
>      )
>    )
>

>
>


--
Dave C. Johnson

href="mailto:djohnson@wwcengineering.com">
size=2>djohnson@wwcengineering.com

WWC
Engineering
Sheridan WY.
Windows xp pro
Acad Map 2008
Carlson
2008
Message 7 of 9
Anonymous
in reply to: Anonymous

Here's your new layout.

(if (= ab 1)

(progn

;;

;; ab = 1 process

(if (< px1 qx1)

(progn

(command "_.pline" ti2 vert horz "")

(command "text" "j" "mc" htxt ht "0" slopet)

(command "text" "j" "mc" vtxt ht "0" t3sl)

); progn

); if

(if (> px1 qx1)

(progn

(command "_.pline" ti2 vert horz1 "")

(command "text" "j" "mc" htxt2 ht "0" slopet)

(command "text" "j" "mc" vtxt2 ht "0" t3sl)

); progn

); if

;;

); progn

;; else if ab (not) = 1

(progn

;;

;; ab (not) = 1 process

(if (< px1 qx1)

(progn

(command "_.pline" ti3 vert2 horz2 "")

(command "text" "j" "mc" htxt4 ht "0" slopet)

(command "text" "j" "mc" vtxt4 ht "0" t3sl)

); progn

); if

(if (> px1 qx1)

(progn

(command "_.pline" ti3 vert2 horz2 "")

(command "text" "j" "mc" htxt4 ht "0" slopet)

(command "text" "j" "mc" vtxt3 ht "0" t3sl)

); progn

); if

;;

); progn

); if

Bob
Message 8 of 9
Anonymous
in reply to: Anonymous

thank you both. between the both of you I was able to get it to work, and it even made a little
sense to me. Got one more thing to work out and a little more testing and cleanup to do and it
should be done.
Once I finish it up I will post it to see what everyone thinks and to use. might not be until next
week though.

thanks for the help



--
Dave C. Johnson
Message 9 of 9
Anonymous
in reply to: Anonymous

You're welcome, Dave.


"djohnson" a écrit dans le message de news:
6110022@discussion.autodesk.com...
thank you both. between the both of you I was able to get it to work, and
it even made a little
sense to me. Got one more thing to work out and a little more testing and
cleanup to do and it
should be done.
Once I finish it up I will post it to see what everyone thinks and to use.
might not be until next
week though.

thanks for the help



--
Dave C. Johnson

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost