Jump to content

im newbie please help me with this routine


jdbond

Recommended Posts

(defun Section_print()
                 (setvar "osmode" 0)
      (setq sc2(/ sc1 100))
      (setq oo1(list(- (car set3) (* sc2 1.500)) (- (cadr set3) (* sc2 0.700)))
            oo2(list(- (car set3) (* sc2 1.300)) (- (cadr set3) (* sc2 1.380)))
            oo3(list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 0.215)))
            oo4(list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 0.645)))
            oo5(list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 1.075)))
            oo6(list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 1.505)))
            sca(rtos (* 1 sc1) 2 2)
            scp(/ 1000 sc1)
      )
      (Command "style" "mntn" "microsoft Yi Baiti" "2" "1" "0" "n" "n") 
      (command "insert" tbn set3 sc2 sc2 0)
      (command "mtext" oo1 "j" "mc" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) cro "")
      (command "mtext" oo2 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) sca "")
      (command "mtext" oo3 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 6) des "")
      (command "mtext" oo4 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) dat "")
      (command "mtext" oo5 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) dra "")
      (command "mtext" oo6 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) drb "")
)

(defun C:Single_print()
      (setq ch1(getreal "What ch .."))
      (setq chpdf (fix ch1))
      (setq pdfsaveA (itoa chpdf))
      (setq pdfsaveB (strcat "CH " pdfsaveA))
      (setq pdfsaveC (strcat pdfsave pdfsaveB))
      (setq set1(/ sett incrs)
            set2(* set1 ch1)
            bloh(* bh -8)
            bupc(- 0.25 bh)
           blowc(- (+ 0.25 bh))
      )
                 (setvar "osmode" 0)
      (command "zoom" "c" (list set2 0) 300)
               (setq s1(ssget "w"
                  (list(- set2 200) bupc)
                  (list(+ set2 200) blowc)))
               (setq na (entget (ssname s1 0)))
             (setq set4 (cdr (assoc 10 na)))
             (setq set5 (cdr (assoc 11 na)))
             (setq set6 (/ (+ (car set5) (car set4)) 2))
             (setq set3(list set6 bloh))
           (Section_print)
      (setq xx3(list(+ (car set3) (* sc2 13.76)) (- (cadr set3) (* sc2 2.51)))
            xx4(list(- (car set3) (* sc2 13.76)) (+ (cadr set3) (* sc2 16.310)))
            xx5(list(- (car set3) (* sc2 13.76)) (+ (cadr set3) (* sc2 0.1)))
      )
     ; (command "zoom" "p")
       (if (= pdf_pri 1)
            (command "plot" "y" "" ptde "ISO expand A4 (297.00 x 210.00 MM)" "m" "l" "" "w" xx3 xx4 scp "c" "y" "" "y" "" pdfsaveC "n" "y")
            (command "plot" "y" "" ptde "A4 (210 x 297 MM)" "M" "L" "" "w" xx3 xx4 scp "0,0" "" "" "" "" "" "" "")
       ) 
      (command "erase" "C" xx3 xx5 "")
      ;(command "plot" "w" xx3 xx4 "5" "n" "n" "m" "0,0" "90" "n" "n" scp "0")
)

(defun C:All_print()
      (setq ch1(getreal"From CH ...  ")
            cht(getreal"To CH ...  "))
      (setq tole(- cht ch1)
               k(fix(1+ (/ tole incrs)))
      )
  (repeat k
      (setq chf ch1)
      (setq chpdf (fix ch1))
      (setq pdfsaveA (itoa chpdf))
      (setq pdfsaveB (strcat "CH " pdfsaveA))
      (setq pdfsaveC (strcat pdfsave pdfsaveB))
      (setq set1(/ sett incrs)
            set2(* set1 ch1)
            bloh(* bh -8)
            bupc(- 0.25 bh)
           blowc(- (+ 0.25 bh))
      )  
                 (setvar "osmode" 0)
      (command "zoom" "c" (list set2 0) 200)
               (setq s1(ssget "w"
                  (list(- set2 200) bupc)
                  (list(+ set2 200) blowc)))
               (setq na (entget (ssname s1 0)))
             (setq set4 (cdr (assoc 10 na)))
             (setq set5 (cdr (assoc 11 na)))
             (setq set6 (/ (+ (car set5) (car set4)) 2))
             (setq set3(list set6 bloh))
           (Section_print)
      (setq xx3(list(+ (car set3) (* sc2 13.76)) (- (cadr set3) (* sc2 2.51)))
            xx4(list(- (car set3) (* sc2 13.76)) (+ (cadr set3) (* sc2 16.31)))
            xx5(list(- (car set3) (* sc2 13.76)) (+ (cadr set3) (* sc2 0.1)))
      )
       (if (= pdf_pri 1)
           (command "plot" "y" "" ptde "ISO expand A4 (297.00 x 210.00 MM)" "m" "l" "" "w" xx3 xx4 scp "c" "y" "" "y" "" pdfsaveC "n" "y")
           (command "plot" "y" "" ptde "A4 (210 x 297 MM)" "M" "L" "" "w" xx3 xx4 scp "0,0" "" "" "" "" "" "" "")
       ) 
      (command "erase" "C" xx3 xx5 "")
      ;(command "plot" "w" xx3 xx4 "5" "n" "n" "m" "5,5" "90" "n" "n" scp "0")
      (setq ch1(+ incrs chf))  
      (command "zoom" "p")
  )
)
==============================================================================
(defun C:Section_preview()
      (setq ch1(getreal "What ch .."))
      (Section_preview1)
)

(defun Section_preview1()
      (setq set1(/ sett incrs)
            set2(* set1 ch1)
            set3(list set2 0)
            bloh(* bh -8)
            bupc(- 0.25 bh)
           blowc(- (+ 0.25 bh))
      )
                 (setvar "osmode" 0)
           (command "zoom" "c" set3 200)
               (setq s1(ssget "w"              
                  (list(- set2 200) bupc)
                  (list(+ set2 200) blowc)))
             (setq nat (entget (ssname s1 0)))
             (setq set4 (cdr (assoc 10 nat)))
             (setq set5 (cdr (assoc 11 nat)))
             (setq set6 (/ (+ (car set5) (car set4)) 2))
             (setq set3(list set6 bloh))
      (setq sc1(getreal "Scale 1:"))
      (setq sc2(/ sc1 100))
      (setq xx1(list(+ (car set3) (* sc2 14)) (- (cadr set3) (* sc2 3)))
            xx2(list(- (car set3) (* sc2 13)) (+ (cadr set3) (* sc2 20)))
      )
      (command "zoom" "w" xx1 xx2)
      (command "insert" tbn set3 sc2 sc2 0)
      (setq yon(getstring "View to Next Ch? (Yes/No).."))
      (command "zoom" "p")
             (Form_Erase)
)

(defun Form_Erase()
      (command "erase" set3 "")
         (if (= yon "y")
             (Section_preview2)
             (               )
         )
)

(defun Section_preview2()
      (setq ch1(getreal "What ch .."))
             (Section_preview1)
)
==============================================================================

Link to comment
Share on other sites

Someone is going to moan and ask if you can put the code in code tags ( if you edit your post, click on the '<>'  button and paste the code in there?)

 

Someone else is going to ask what the problem is? What is the code meant to do and where does it all go wrong. A little description will help helping easier

 

 

A very quick look, in the plot line, you have 'ptde' but that isn't defined

Edited by Steven P
Link to comment
Share on other sites

Just coming back to this for a quick look, and on the basis you will learn more by fixing something yourself rather than copying and pasting what someone else has fixed....

You'll need to define these in single_print:

pdfsave
sett
incrs
bh

and the CRO,  SCA, DES and so on in the MTEXTs
 

I assume your drawing will have a block named tdn, otherwise you will need to also define what tdn should be

 

and in section print add this before (setq sc2...)

(setq sc1(getreal "Scale 1:"))

 

That will get you a bit closer to fixing it. post your fixed code say what any problems are and see where you go from there

Link to comment
Share on other sites

Steven posted 'just' before I was able to post and have made some comments for the first half of your code but its ba-sick-ly what Steven said : some variables are not set , not by the code you posted anyway. Also you should localize your variables and maybe think about some better names for your variables unless you want to become the human Kelvinator (some know what I mean and some probably not haha)

 

(defun Section_print ( / )
  (setvar "osmode" 0)
  ;;; unknown : sc1
  (setq sc2 (/ sc1 100))
  (setq oo1 (list(- (car set3) (* sc2 1.500)) (- (cadr set3) (* sc2 0.700)))
        oo2 (list(- (car set3) (* sc2 1.300)) (- (cadr set3) (* sc2 1.380)))
        oo3 (list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 0.215)))
        oo4 (list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 0.645)))
        oo5 (list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 1.075)))
        oo6 (list(- (car set3) (* sc2 11.90)) (- (cadr set3) (* sc2 1.505)))
        sca (rtos (* 1 sc1) 2 2)
        scp (/ 1000 sc1)
  )

  (Command "style" "mntn" "microsoft Yi Baiti" "2" "1" "0" "n" "n")

  ;;; unknown tbn 
  (command "insert" tbn set3 sc2 sc2 0)
  (command "mtext" oo1 "j" "mc" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) cro "")
  (command "mtext" oo2 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) sca "")
  (command "mtext" oo3 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 6) des "")
  (command "mtext" oo4 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) dat "")
  (command "mtext" oo5 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) dra "")
  (command "mtext" oo6 "j" "ml" "h" (* sc2 0.120) "r" 0 "w" (* sc2 4) drb "")
)

(defun C:Single_print
       ;;; localize your variables
       ( / ch1 chpdf pdfsaveA pdfsaveB pdfsaveC set1 set2 bloh bupc blowc s1 na set4 set5 set6 set3 xx3 xx4
        ;;; other variabbles that could be localized here / are missing in action
        pdfsave sett incrs bh sc1 sc2 pdf_pri ptde scp
       )
  
  ;;; *** chpdf not needed if you use getint instead of getreal?
  ;;; *** (setq ch1 (getint "\nWhat ch.? : ") pdfsaveA (itoa ch1))
  (setq ch1 (getreal "What ch ..")) (setq chpdf (fix ch1)) (setq pdfsaveA (itoa chpdf))

  (setq pdfsaveB (strcat "CH " pdfsaveA))
  
  ;;; unknown : pdfsave
  (setq pdfsaveC (strcat pdfsave pdfsaveB))

  ;;; unknown : sett , incrs , bh
  (setq set1 (/ sett incrs) set2 (* set1 ch1) bloh  (* bh -8) bupc  (- 0.25 bh) blowc (- (+ 0.25 bh)))
  
  (setvar "osmode" 0)
  (command "zoom" "c" (list set2 0) 300)

  ;;; *** if nothing is selected ssget will be nil so test for this with IF or some like to use it in AND statement
  (if (setq s1 (ssget "w" (list (- set2 200) bupc) (list (+ set2 200) blowc)))
    (progn
      (setq na (entget (ssname s1 0)))
      (setq set4 (cdr (assoc 10 na)))
      (setq set5 (cdr (assoc 11 na)))
      (setq set6 (/ (+ (car set5) (car set4)) 2))
      (setq set3 (list set6 bloh))
    )
  )

  ;;; section_print uses sc1 , where is this set?
  (Section_print)

  ;;; sc2 is set in section_print so make sure its not localized in section_print
  (setq xx3 (list(+ (car set3) (* sc2 13.76)) (- (cadr set3) (* sc2 2.51)))
        xx4 (list(- (car set3) (* sc2 13.76)) (+ (cadr set3) (* sc2 16.310)))
        xx5 (list(- (car set3) (* sc2 13.76)) (+ (cadr set3) (* sc2 0.1)))
  )
  ; (command "zoom" "p")

  ;;; *** unknowns : pdf_pri , ptde , scp
  (if (= pdf_pri 1)
    (command "plot" "y" "" ptde "ISO expand A4 (297.00 x 210.00 MM)" "m" "l" "" "w" xx3 xx4 scp "c" "y" "" "y" "" pdfsaveC "n" "y")
    (command "plot" "y" "" ptde "A4 (210 x 297 MM)" "M" "L" "" "w" xx3 xx4 scp "0,0" "" "" "" "" "" "" "")
  ) 
  (command "erase" "C" xx3 xx5 "")
  ;;; (command "plot" "w" xx3 xx4 "5" "n" "n" "m" "0,0" "90" "n" "n" scp "0")
)

 

  • Like 1
Link to comment
Share on other sites

Not sure what your mtext is doing looks like a Title block so why not just do that have a Title Block with attributes so much easier. 

 

There are so many plot lisps out there, for me a Plot PDF by layout range can enter start and end of layouts to plot.

 

Re using a "Title Block" I have a few lisps that read all layouts and update like 1 of X before plotting. Copy attributes from layout1 to all layouts and so on.

Link to comment
Share on other sites

I have used these lips before for cross section print. When I use it again, it doesn't seem to work. I don't know where the mistake is. i took it from my friend. 

Link to comment
Share on other sites

Ok understand now my best suggestion is get  better software I used Cvil Site Design lays the cross sections out to new file or layouts.

 

For me looking at what you have I would make into multiple cross sections per layout would be way better as the first step just pick a lower left upper right to define the cross section size so like 180 x 80 with a spacing factor, so end up with stacked cross sections. Then can use a layout this can also be automated with a title block. A much better solution.

 

I am pretty sure a rearrange cross sections exists.

 

image.png.bb051d19d5b1ed9eb2aaa9a4cf7ee642.png

Link to comment
Share on other sites

So your happy ?

 

A simple way for the crossections is draw grid lines and move them to intersection points, then erase grid.

Edited by BIGAL
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...