DIMSTYLE GETVAR

anieves228
Enthusiast
Enthusiast

DIMSTYLE GETVAR

anieves228
Enthusiast
Enthusiast

Hi all! 

I'm trying to create dimension styles with lisps. Now did it, but I'm trying to as a cond or if to it.  I want o the lisp to check if the dim style is there and if not to add it. I'm trying to use (getvar "dimstyle) but it's not working.

 

What am I missing to add the condition with dimstyle?

 

Thank you!

 

here is my code.

 

	(DEFUN C:TDIM1 ()
		
		(SETQ STYLE
			(GETVAR "-DIMSTYLE")
		)
				
		(cond 
			( ( EQUAL STYLE "Current dimension style: Standard") (C:TERRADIM1) )
		)
		
		(PRINC)
	)
	

	(DEFUN C:TERRADIM1 ()
			
		(SETVAR "CMDECHO" 0)
		
			(COMMAND "-DIMSTYLE" 
			"ANNOTATIVE"
			"YES"
			"TERRA 0.1"
			"RESTORE"
			"TERRA 0.1"
			)
			

	
			(SETVAR "DIMASZ"		0.1000			)		;Arrow size
			(SETVAR "DIMCEN"		0.1000			)		;Center mark size
			(SETVAR "DIMEXE"		0.1000			)		;Extension above dimension line
			(SETVAR "DIMEXO"		0.1000			)		;Extension line origin offset	
			(SETVAR "DIMGAP"		0.1000			)		;Gap from dimension line to text	
			(SETVAR "DIMDLI"		0.1000			)		;Dimension line spacing
			(SETVAR "DIMTXSTY"		"TERRA 0.1"		)		;Text style
		
		
		(SETVAR "DIMFXL"		1.0000			)		;Fixed Extension Line
		(SETVAR "DIMADEC"		0				)		;Angular decimal places
		(SETVAR "DIMARCSYM"		0				)		;Arc length symbol	
		(SETVAR "DIMATFIT"		3				)		;Arrow and text fit
		(SETVAR "DIMAUNIT"		0				)		;Angular unit format
		(SETVAR "DIMAZIN"		0				)		;Angular zero supression
		(SETVAR "DIMBLK"		"."				)		;Arrow block name
		(SETVAR "DIMBLK1"		"."				)		;First arrow block name
		(SETVAR "DIMBLK2"		"."				)		;Second arrow block name
		(SETVAR "DIMCLRD"		256				)		;Dimension line and leader color
		(SETVAR "DIMCLRE"		256				)		;Extension line color
		(SETVAR "DIMCLRT"		256				)		;Dimension text color
		(SETVAR "DIMDEC"		1				)		;Decimal places
		(SETVAR "DIMDLE"		0.0000			)		;Dimension line extension
		(SETVAR "DIMFRAC"		0				)		;Fraction format
		(SETVAR "DIMFXLON"		0				)		;Enable Fixed Extension Line ON/OFF (1/0)
		(SETVAR "DIMJUST"		0				)		;Justification of text on dimension line
		(SETVAR "DIMLDRBLK"		"."				)		;Leader block name
		(SETVAR "DIMLFAC"		1.0000			)		;Linear unit scale factor
		(SETVAR "DIMLUNIT"		3				)		;Linear unit format
		(SETVAR "DIMLWD"		-2				)		;Dimension line and leader lineweight
		(SETVAR "DIMLWE"		-2				)		;Extension line lineweight
		(SETVAR "DIMRND"		0.0000			)		;Rounding value
		(SETVAR "DIMTAD"		1				)		;Place text above the dimension line
		(SETVAR "DIMTDEC"		1				)		;Tolerance decimal places
		(SETVAR "DIMTFAC"		1.0000			)		;Tolerance text height scaling factor
		(SETVAR "DIMTFILL"		0				)		;Text background enabled
		(SETVAR "DIMTFILLCLR"	256				)		;Text background color
		(SETVAR "DIMTIH"		1				)		;Text inside extensions is horizontal ON/OFF (1/0)
		(SETVAR "DIMTIX"		0				)		;Place text inside extensions ON/OFF (1/0)
		(SETVAR "DIMTM"			0.0000			)		;Minus tolerance
		(SETVAR "DIMTMOVE"		0				)		;Text movement


			(COMMAND "-DIMSTYLE" 
			"SAVE"
			"TERRA 0.1"
			"YES"
			)

		(SETVAR "CMDECHO" 1)
		
		(PROMPT "\n CREATED GSG TERRA 0.1 DIMENSION STYLE")
		
		(PRINC)
	)
0 Likes
Reply
Accepted solutions (2)
2,795 Views
8 Replies
Replies (8)

Kent1Cooper
Consultant
Consultant
Accepted solution

@anieves228 wrote:
....What am I missing to add the condition with dimstyle? ....
	(DEFUN C:TDIM1 ()
		(SETQ STYLE
			(GETVAR "-DIMSTYLE")
		)	
		(cond 
			( ( EQUAL STYLE "Current dimension style: Standard") (C:TERRADIM1) )
		)
		(PRINC)
	)
....	

 

That part should be more like [untested]

	(DEFUN C:TDIM1 ()
		(SETQ DSTYLE ; avoid confusion -- don't use a command or function name
			(GETVAR 'DIMSTYLE); no hyphen [used for commands - not applicable in (getvar)]
		)
		(cond
			( ( EQUAL DSTYLE "Standard") (C:TERRADIM1) )
;; [what (getvar 'dimstyle) returns is just Dimension Style name string -- no prompt context] ) (PRINC) ) ....

You can leave the (getvar) with the surrounding double-quotes instead of the single preceding apostrophe [but no hyphen]:
    (getvar "dimstyle")

if you prefer -- either way works in both (getvar) and (setvar) functions.

 

If there's only the one current-DimStyle condition to check, it can just be an (if) function:

(if (= DSTYLE "Standard") (C:TERRADIM1))

[saving a few parentheses].  Also, I used the (=) function there instead of (equal) -- that's enough for text-string values [and for numbers if you don't need a fuzz factor].

 

Consider whether the Style name may have gotten capitalized to "STANDARD", and if that's a possibility, this will cover any case or case combination:

(if (= (strcat DSTYLE) "STANDARD") (C:TERRADIM1))

That would also be worth doing if you will add additional conditions with different names to check for, in case some User may have called a Dimension Style "George" but some other User might have called it "GEORGE" and some other user "george".

Kent Cooper, AIA
0 Likes

dbhunia
Advisor
Advisor

@anieves228 go through the last post of 》This《

 

You will get how to check....


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes

Kent1Cooper
Consultant
Consultant
Accepted solution

@anieves228 wrote:
....  I want the lisp to check if the dim style is there and if not to add it. ....

 

Looking back at that original Message, I think you're not checking for the right thing.  According to the quoted phrase above, you don't want to make a new Dimension Style only if the current Dimension Style happens to be "Standard" as the top of your code was trying to check for.  You should be checking for whether the one you want exists:

 

(if (not (tblsearch "dimstyle" "TERRA 0.1")) (C:TERRADIM1))
Kent Cooper, AIA
0 Likes

dbhunia
Advisor
Advisor

Try with this only....... if other things are ok as per you.......

 

(DEFUN C:TDIM1 ()
	(SETQ STYLE (GETVAR "DIMSTYLE")) ;;;;;Not "-DIMSTYLE"
	(cond ((EQUAL STYLE "Standard") (C:TERRADIM1)))
;;; or ((EQUAL STYLE "Current dimension style: Standard") (C:TERRADIM1)) (PRINC) )

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes

anieves228
Enthusiast
Enthusiast

As I was going through what you initially sent me I was just about to ask that. Thank you! it works. 

Also for my information, I can do that in a cond if i want too or need? or it's not needed in a cond?

0 Likes

scot-65
Advisor
Advisor
A COND is simply multiple IF's...

Generally speaking, the COND structure is unique to the LISP programming language.
(COND
((test #1) [...])
((test #2) [...])
((test #3) [...]) ;etc.
(T [...]) ;execute this statement when all tests above fails. "T" is a reserved letter.
);COND

Most other programming languages use the following equivalent...
IF (test #1) {
[...]
}
ElseIf (test #2) {
[...]
}
ElseIf (test #3) {
[...]
}
Else {
[...]
}

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


0 Likes

dgorsman
Consultant
Consultant

@Kent1Cooper - I think that string case compensation would be a (strcase...) rather than a (strcat...).

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Kent1Cooper
Consultant
Consultant

@dgorsman wrote:

@Kent1Cooper - I think that string case compensation would be a (strcase...) rather than a (strcat...).


Yes, indeed.

(if (= (strcase DSTYLE) "STANDARD") (C:TERRADIM1))
Kent Cooper, AIA