Author Topic: I ran out of time  (Read 2755 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
I ran out of time
« on: June 26, 2007, 02:36:14 PM »
I need help on finishing this up.  I got yank on to a big project and have tabled this routine.  Now that this project is kicking off and the routine is needed in short order. I searched here and there but not all over for some code that I can tear apart but cant seem to find any.   I trying to figure out how to pass a field into attribute of block that the routine is inserting. 

This is how I am going about (right or wrong).
Thanks
Code: [Select]
;;; Pass-Area-2-RmTag Lisp
;;;
;;; Purpose = Pulls "Area" Value from User Selected PolyLine
;;;         = Inserts new Room Tag Block
;;;         = Pass Data from Polyline to new RoomTag Block
;;;
;;; Sub-Functions = None @ this Time
;;;
;;; Revisions = None @ this Time

;;; 2007-05-31 = Ted Krush with a lot help from TheSwamp.org
;;;
;;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

(defun c:A2R () ;CE PlineID fieldstring ToRmnaTag)
  (princ)

;;;  GATHERING OF CURRENT SETTINGS AND PRESETTING VARIABLES AS REQUIRED.
  (vl-load-com)
  (vl-cmdf ".undo" "m")
  (setq ce (getvar "CMDECHO"))
  (setvar "CMDECHO" 1)
  (setq clay (getvar "clayer"))
  (setq atd (getvar "attdia"))
  (setvar "attdia" 1)
  (setq atr (getvar "attreq"))
  (setvar "attreq" 0)


;;;; User Selection of Closed PolyLine and test thereof
  (IF (setq ent (entsel "\n Select a closed polyline:"))
; test to see if object was selected
    (progn
      (setq ent (car ent)) ; test to see if object selcted is a PLine
      (if (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
(progn
  (setq PlineID (vla-get-objectid
; obtain the object id from the selected
  (vlax-ename->vla-object ent)
)
  )
)
(prompt "/n Object selected was not a Pline.")
      )
    )
    (prompt "/n No Object was selected.")
  )

;;;; Generating of FeildString Variable
;;;; Use the FIELD-command to compose the next line:  (itoa PlineID)
  (setq fieldstring
(strcat
   "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
   (itoa PlineID)
   ">%).Area \\f \"%lu2%pr1%ct8[0.006944444444444444]\">%"
)
  )

;;; INSERTS NEW ROOM TAG BLOCK BUT FIRST GETS DIMSCALE AND SET LAYER "RMNA-N" CURRENT
;;; Room Tag Block has 5 Attributes; Name1, Name2, Name3, Number, & SqFt.  All will be left blank but SqFt.
  (SETQ DSS (GETVAR "DIMSTYLE"))
  (VL-CMDF "-DIMSTYLE" "R" DSS)
  (SETQ DS (getvar "dimscale"))


  (VL-CMDF "-LAYER" "T" "RMNA-N" "M" "RMNA-N" "C" "124" "RMNA-N" "")

  (VL-CMDF "-insert" "m:/autoca~1/genera~1/RmTag-SqFt"
   "SCALE" DS
   "ROTATE" 0.0
   pause
  )

  (SETQ NewRTBlock
(vla-get-objectid
   (vlax-ename->vla-object
     (ENTLAST)
   )
)
  )


;;; PASS FIELD TO "SQFT" ATTRIBUTE


;;; RESTORE USERS SET VARIBLES.
  (VL-CMDF "LAYER" "S" CLAY "")
  (setvar "attreq" atr)
  (setvar "attdia" atd)
  (setvar "CMDECHO" ce)
  (princ)
) ; END OF ROUTINE
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7531
Re: I ran out of time
« Reply #1 on: June 26, 2007, 02:53:42 PM »
Give this a try...not tested but I think you are trying to insert the field linked to the polyline into the attribute of a block you just inserted?

Code: [Select]
;;; Pass-Area-2-RmTag Lisp
;;;
;;; Purpose = Pulls "Area" Value from User Selected PolyLine
;;;         = Inserts new Room Tag Block
;;;         = Pass Data from Polyline to new RoomTag Block
;;;
;;; Sub-Functions = None @ this Time
;;;
;;; Revisions = None @ this Time

;;; 2007-05-31 = Ted Krush with a lot help from TheSwamp.org
;;;
;;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

(defun c:A2R () ;CE PlineID fieldstring ToRmnaTag)
  (princ)

;;;  GATHERING OF CURRENT SETTINGS AND PRESETTING VARIABLES AS REQUIRED.
  (vl-load-com)
  (vl-cmdf ".undo" "m")
  (setq ce (getvar "CMDECHO"))
  (setvar "CMDECHO" 1)
  (setq clay (getvar "clayer"))
  (setq atd (getvar "attdia"))
  (setvar "attdia" 1)
  (setq atr (getvar "attreq"))
  (setvar "attreq" 0)


;;;; User Selection of Closed PolyLine and test thereof
  (IF (setq ent (entsel "\n Select a closed polyline:"))
; test to see if object was selected
    (progn
      (setq ent (car ent)) ; test to see if object selcted is a PLine
      (if (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
(progn
  (setq PlineID (vla-get-objectid
; obtain the object id from the selected
  (vlax-ename->vla-object ent)
)
  )
)
(prompt "/n Object selected was not a Pline.")
      )
    )
    (prompt "/n No Object was selected.")
  )

;;;; Generating of FeildString Variable
;;;; Use the FIELD-command to compose the next line:  (itoa PlineID)
  (setq fieldstring
(strcat
   "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
   (itoa PlineID)
   ">%).Area \\f \"%lu2%pr1%ct8[0.006944444444444444]\">%"
)
  )

;;; INSERTS NEW ROOM TAG BLOCK BUT FIRST GETS DIMSCALE AND SET LAYER "RMNA-N" CURRENT
;;; Room Tag Block has 5 Attributes; Name1, Name2, Name3, Number, & SqFt.  All will be left blank but SqFt.
  (SETQ DSS (GETVAR "DIMSTYLE"))
  (VL-CMDF "-DIMSTYLE" "R" DSS)
  (SETQ DS (getvar "dimscale"))


  (VL-CMDF "-LAYER" "T" "RMNA-N" "M" "RMNA-N" "C" "124" "RMNA-N" "")

  (VL-CMDF "-insert" "m:/autoca~1/genera~1/RmTag-SqFt"
   "SCALE" DS
   "ROTATE" 0.0
   pause
  )

  (setq NewRTBlock
(vlax-ename->vla-object
   (entlast)
)
  )

;;; PASS FIELD TO "SQFT" ATTRIBUTE

  (mapcar
    '(lambda (x)
       (if (= "SQFT" (strcase (vla-get-tagstring x)))
(progn
   (vla-put-textstring x fieldstring)
   (vla-update x)
)
       )
     )
    (vlax-invoke NewRTBlock 'getattributes)
  )


;;; RESTORE USERS SET VARIBLES.
  (VL-CMDF "LAYER" "S" CLAY "")
  (setvar "attreq" atr)
  (setvar "attdia" atd)
  (setvar "CMDECHO" ce)
  (princ)
) ; END OF ROUTINE

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: I ran out of time
« Reply #2 on: June 26, 2007, 03:02:39 PM »
Give this a try...not tested but I think you are trying to insert the field linked to the polyline into the attribute of a block you just inserted?

Exactly what I what I was trying to do and it works like a charm.  Thank you very much. 
The next round is on me.  :-D
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7531
Re: I ran out of time
« Reply #3 on: June 26, 2007, 03:07:16 PM »
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

LE

  • Guest
Re: I ran out of time
« Reply #4 on: June 26, 2007, 03:07:30 PM »
Just a minor stuff... if I may...

There are some calls of /n ... change them to \n



Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: I ran out of time
« Reply #5 on: June 26, 2007, 03:22:35 PM »
Just a minor stuff... if I may...

There are some calls of /n ... change them to \n



Gracias Senior
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans