Author Topic: Adding a Block at the begining of a line  (Read 3038 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding a Block at the begining of a line
« on: February 17, 2005, 10:53:54 AM »
I want to add a block when the user picks the first point for the elev. to come in. The Block name is SPOT and its just a "X". I keep messing w/ it and it blows up.

thank you for the help


Code: [Select]

(defun c:S2 ()
(setq Pt1 (getpoint"\nPick point for the elevation: ")
      Pt2 (getpoint Pt1 "nPick elevation label point: ")
)
(setq BkName (if (> (car Pt2) (car Pt1))  "SpotRight1" "SpotLeft1"))
(setq SpotElev (getreal "\nEnter Top Curb Elevation: ")
      SpotHIGH (+ 0.5 SpotElev)
      SpotElevTxt (rtos SpotElev 2 2)
      SpotHighTxt (rtos SpotHigh 2 2)
)
(command "line" pt1 pt2 "")
(command "-insert" BkName Pt2 TxtHt TxtHt 0 SpotElevTxt SpotHighTxt)
(princ)
)
[/code]
Civil3D 2020

whdjr

  • Guest
Adding a Block at the begining of a line
« Reply #1 on: February 17, 2005, 11:21:32 AM »
First of all you say the block name is "SPOT", but in your code you call it "SpotRight1" and "SpotLeft1".  The block name has to be consistent.

whdjr

  • Guest
Adding a Block at the begining of a line
« Reply #2 on: February 17, 2005, 11:25:48 AM »
Also you have too many inputs for the insert command.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Adding a Block at the begining of a line
« Reply #3 on: February 17, 2005, 11:33:41 AM »
Looks like you are trying to update the attributes during the Insert.
I don't think it can be done that way.
You mat have to set ATTREQ to 0 and update the attributes after the insert.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Adding a Block at the begining of a line
« Reply #4 on: February 17, 2005, 01:01:48 PM »
It worked for me once I had 2 blocks defined with 2 attributes each and named SpotRight1 & SpotLeft1. I also had to change the insert portion to use a scale factor of 1 since the variable TxtHt  is not defined.

whdjr

  • Guest
Adding a Block at the begining of a line
« Reply #5 on: February 17, 2005, 01:20:36 PM »
You would cut down on your potential errors by localizing the variables:
Code: [Select]
(defun c:S2 (/ Pt1 Pt2 BkName SpotElev SpotHIGH SpotElevTxt SpotHighTxt )

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding a Block at the begining of a line
« Reply #6 on: February 17, 2005, 01:29:14 PM »
I have the blocks worked out...

XXX.50______(X)<----  this is the piece i want
XXX.00

User picks the first point. a block (SPOT) (X) shows up... and then the rest of the command follows..
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Adding a Block at the begining of a line
« Reply #7 on: February 17, 2005, 01:46:47 PM »
Hmmm, you mean like this?
Code: [Select]

(setq Pt1 (getpoint"\nPick point for the elevation: "))
  (command "-insert" "spot" pt1 1.0 1.0 0.0)
  (setq Pt2 (getpoint Pt1 "\nPick elevation label point: "))

(setq BkName (if (> (car Pt2) (car Pt1))  "SpotRight1" "SpotLeft1"))

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding a Block at the begining of a line
« Reply #8 on: February 17, 2005, 01:58:43 PM »
i get an error
Desktop/spot.lsp") ;
error: malformed list on input


Code: [Select]

(setq Pt1 (getpoint"\nPick point for spot elevation: ")
      (command "-insert" "spot" pt1 1.0 1.0 0.0)
      (Pt2 (getpoint Pt1 "nType elevation label point: "))

(setq BkName (if (> (car Pt2) (car Pt1))  "SpotRight" "SpotLeft"))
(setq SpotElev (getreal "\nType Spot elevation: ")
      SpotHigh (+ 0.5 SpotElev)
      SpotElevTxt (rtos SpotElev 2 2)
      SpotHighTxt (rtos SpotHigh 2 2)
)
(command "line" pt1 pt2 "")
(command "-insert" BkName Pt2 TxtHt TxtHt 0 SpotElevTxt SpotHighTxt)
(princ)
)
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Adding a Block at the begining of a line
« Reply #9 on: February 17, 2005, 02:24:52 PM »
Look carefully at the code I posted and the code you posted....specifically the (setq .... and the closing parenthesis........

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding a Block at the begining of a line
« Reply #10 on: February 17, 2005, 02:49:26 PM »
now it just goes into the Enter Elevation...

Code: [Select]


(setq Pt1 (getpoint"\nPick point for elevation: "))
      (command "-insert" "spot" pt1 1.0 1.0 0.0)
      Pt2 (getpoint Pt1 "nPick elevation label point: "))

(setq BkName (if (> (car Pt2) (car Pt1))  "SpotRight" "SpotLeft"))
(setq SpotElev (getreal "\nEnter elevation: ")
      SpotHigh (+ 0.5 SpotElev)
      SpotElevTxt (rtos SpotElev 2 2)
      SpotHighTxt (rtos SpotHigh 2 2)
)
(command "line" pt1 pt2 "")
(command "-insert" BkName Pt2 TxtHt TxtHt 0 SpotElevTxt SpotHighTxt)
(princ)
)

Civil3D 2020

whdjr

  • Guest
Adding a Block at the begining of a line
« Reply #11 on: February 17, 2005, 03:14:16 PM »
Add (setq in front of the first Pt2. :(

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding a Block at the begining of a line
« Reply #12 on: February 17, 2005, 03:48:43 PM »
got it! understand! thank you!
Civil3D 2020