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

Diesel exrpessions - embed if

5 REPLIES 5
Reply
Message 1 of 6
benyo23
910 Views, 5 Replies

Diesel exrpessions - embed if

I have an issue with this expression:

 

 

$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-1),Áttekintő térkép,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-2),Átnézeti helyszínrajz,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-3),Felmérési helyszínrajz közműállapotterv,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-4),helyszínrjaz,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-5),hossz-szelvény,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-6),Mintakeresztszelvények,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-7),keresztszelvények,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-8),Csapadékvíz elvezetés helyszínrajza,$(if,$(eq,$(substr,$(getvar,ctab),1,4),CS-1),Csapadékvíz hossz-szelvény,$(if,$(eq,$(substr,$(getvar,ctab),1,4),CS-2),Víznyelő összellítási és részletrajzok,$(if,$(eq,$(substr,$(getvar,ctab),1,4),CS-4),Egyesített közműhelyszínrajz,$(if,$(eq,$(substr,$(getvar,ctab),1,3),K-1),Forgalomtechnikai helyszínrajz,xxxx))))))))))))

 

 

I would like to get text based on the layout tab first 3 or 4 characters. I tried to bild step by setp. It works until the third layer:

 

 

$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-1),Áttekintő térkép,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-2),Átnézeti helyszínrajz,$(if,$(eq,$(substr,$(getvar,ctab),1,3),U-3),Felmérési helyszínrajz közműállapotterv)))

 

 

 

Does any body an idea why it is not working. I write the equations in excel, which is works fine. I tried to "translate" that to diesel. 

 

 

=IF(A1="U-1";"Áttekintő térkép";IF(A1="U-2";"Átnézeti helyszínrajz";IF(A1="U-3";"Felmérési helyszínrajz közműállapotterv";IF(A1="U-4";"helyszínrjaz";IF(A1="U-5";"hossz-szelvény";IF(A1="U-6";"Mintakeresztszelvények";IF(A1="U-7";"keresztszelvények";IF(A1="CS-1";"Csapadékvíz elvezetés helyszínrajza";IF(A1="CS-2";"Csapadékvíz hossz-szelvény";IF(A1="CS-3";"Víznyelő összellítási és részletrajzok";IF(A1="K-1";"Egyesített közműhelyszínrajz";IF(A1="F-1";"Forgalomtechnikai helyszínrajz"))))))))))))

 

 

 

5 REPLIES 5
Message 2 of 6
ВeekeeCZ
in reply to: benyo23

Welcome to the community forum!

 

It may be just too long, see HERE

 

I presume you're on LT. Otherwise I would recommend to use LISP.

Message 3 of 6
benyo23
in reply to: benyo23

Thank you for your answer. Now I understand why it is not working. I'm using Autocad Civil 3D 2014. Do you have any suggestion how can I make it work?
Message 4 of 6
ВeekeeCZ
in reply to: benyo23

Here is a starting point for your LISP - to get the idea. 

 

(defun c:GetYouName (/ tin tout)

  (setq tin (substr (getvar 'CTAB) 1 3)
	tout (cond ((= tin "U-1")
		    "Áttekintő térkép")
		   ((= tin "U-2")
		    "Átnézeti helyszínrajz")))

  (princ tot)
  (princ)
)

The question is - what are you going to do with the text you've reveive? We could put in into Clipboard, or make text entity... The provided example just prints the text in the command line.

 

If you know nothing about the LISP, see THIS Lee Mac's page how to run it. Typing VLIDE into the command line you'll get into (Visual) LIsp Editor.

 

Message 5 of 6
benyo23
in reply to: benyo23

Thanks you. You're great.
I would like to put the results in the drawing stamps which is a block.

I loaded the the code as you said. I can run, but the result is "nil".
Message 6 of 6
ВeekeeCZ
in reply to: benyo23

There was a typo in the variable name, it should be (princ tout).

 

Anyway, try the following code with

- fill up the rest of the conditions.

- change the block name of the stamp (hope it's not a dynamic block)

- change the attribute name

 

If anything goes wrong, and always in the future, post a dwg example!

 

(vl-load-com)

(defun c:SetLayoutName (/ LM:vl-setattributevalue tin tout ss i)
  
  
  ;; Set Attribute Value  -  Lee Mac
  ;; Sets the value of the first attribute with the given tag found within the block, if present.
  ;; blk - [vla] VLA Block Reference Object
  ;; tag - [str] Attribute TagString
  ;; val - [str] Attribute Value
  ;; Returns: [str] Attribute value if successful, else nil.
  
  (defun LM:vl-setattributevalue ( blk tag val )
    (setq tag (strcase tag))
    (vl-some
      '(lambda ( att )
	 (if (= tag (strcase (vla-get-tagstring att)))
	   (progn (vla-put-textstring att val) val)
	   )
	 )
      (vlax-invoke blk 'getattributes)
      )
    )
  
  ; -----------------------------------------------------------------------------------------------
  
  (if (and (setq tin (substr (getvar 'CTAB) 1 3)
		 tout (cond
						
			((= tin "U-1") 		"Áttekintő térkép")
			((= tin "U-2")		"Átnézeti helyszínrajz")                ; fill up the rest of the conditions
						
			))
	   (setq ss (ssget "_X" (list '(2 . "BlockName")				; change the name of stamp block
				      (cons 410 (getvar 'CTAB)))))
	   )
    
    (repeat (setq i (sslength ss))
      (LM:vl-setattributevalue
	(vlax-ename->vla-object (ssname ss (setq i (1- i))))
	"AttributeName"  								; change the name of attribute
	tout)))
  (princ)
  )

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report